Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions image_processing_course/ipc_s01e01.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,22 @@ def ex_2():
# TODO 4
cv2.imshow('img_color', img_color)
cv2.waitKey(1)

# 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([])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Chaining multiple function calls on a single line using a comma is non-idiomatic in Python and violates PEP 8's recommendation against multiple statements on the same line. For image visualization in Matplotlib, it is more idiomatic to use plt.axis('off') to hide both the axes and the ticks.

Suggested change
plt.xticks([]), plt.yticks([])
plt.axis('off')
References
  1. PEP 8 discourages multiple statements on the same line. Chaining calls with commas creates an implicit tuple and is considered poor style. (link)


plt.subplot(1, 2, 2)
plt.imshow(img_rgb)
plt.title('RGB (Correct)')
plt.xticks([]), plt.yticks([])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

As with the previous subplot, consider using plt.axis('off') instead of chaining xticks and yticks calls. This adheres to PEP 8 and follows standard Matplotlib practices for displaying images.

Suggested change
plt.xticks([]), plt.yticks([])
plt.axis('off')
References
  1. PEP 8 discourages multiple statements on the same line. (link)

plt.tight_layout()

plt.show()
cv2.destroyAllWindows()

Expand Down