Implement Matplotlib image display with BGR/RGB comparison#2
Implement Matplotlib image display with BGR/RGB comparison#2Michal-Fularz wants to merge 1 commit intomasterfrom
Conversation
- Updated ipc_s01e01.py to show BGR and RGB versions in subplots. - Added titles to plots for clarity. - Kept OpenCV imshow for comparison. Co-authored-by: Michal-Fularz <3768498+Michal-Fularz@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request updates the ex_2 function to include a side-by-side comparison of BGR and RGB color spaces using Matplotlib. The feedback suggests enhancing the visualization by adjusting the figure size, removing axis ticks, and using plt.tight_layout() to prevent title overlap and improve overall readability.
| # Convert image to RGB for correct Matplotlib display | ||
| img_rgb = cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB) | ||
|
|
||
| plt.figure() | ||
| plt.subplot(1, 2, 1) | ||
| plt.imshow(img_color) | ||
| plt.title('BGR (Incorrect)') | ||
|
|
||
| plt.subplot(1, 2, 2) | ||
| plt.imshow(img_rgb) | ||
| plt.title('RGB (Correct)') | ||
|
|
There was a problem hiding this comment.
The added code contains excessive blank lines that disrupt the readability of the function. Additionally, for side-by-side comparisons in Matplotlib, it is recommended to use plt.tight_layout() to ensure titles do not overlap and to specify a figsize for better visibility. Hiding the axis ticks with plt.xticks([]) and plt.yticks([]) is also a common practice for image display to focus on the content, as seen in other parts of this repository.
| # Convert image to RGB for correct Matplotlib display | |
| img_rgb = cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB) | |
| plt.figure() | |
| plt.subplot(1, 2, 1) | |
| plt.imshow(img_color) | |
| plt.title('BGR (Incorrect)') | |
| plt.subplot(1, 2, 2) | |
| plt.imshow(img_rgb) | |
| plt.title('RGB (Correct)') | |
| # Convert image to RGB for correct Matplotlib display | |
| img_rgb = cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB) | |
| plt.figure(figsize=(10, 5)) | |
| plt.subplot(1, 2, 1) | |
| plt.imshow(img_color) | |
| plt.title('BGR (Incorrect)') | |
| plt.xticks([]), plt.yticks([]) | |
| plt.subplot(1, 2, 2) | |
| plt.imshow(img_rgb) | |
| plt.title('RGB (Correct)') | |
| plt.xticks([]), plt.yticks([]) | |
| plt.tight_layout() |
Modified TODO 4 in
image_processing_course/ipc_s01e01.pyto display the color image using Matplotlib'simshow. The implementation now includes a side-by-side comparison of the image in its original BGR format and the converted RGB format to highlight the color space differences between OpenCV and Matplotlib.PR created automatically by Jules for task 7117131935577827918 started by @Michal-Fularz