Preface: This is a continuation of this question.
Consider the following code, taken from here:
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('messi5.jpg',0)
edges = cv2.Canny(img,100,200) # Would 100 and 200 matter if your original image was black and white?
plt.subplot(121),plt.imshow(img,cmap = 'gray')
plt.title('Original Image'), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(edges,cmap = 'gray')
plt.title('Edge Image'), plt.xticks([]), plt.yticks([])
plt.show()
My Question:
- When using open cv's canny function, do your choices for minVal and maxVal matter if you're working with a black and white image?
Reason I ask:
- I've experimented with many values and they don't seem to matter.
The threshold values do matter.
Assuming a
3x3
Sobel filter (as inCanny
), the possible values fordx
anddy
you can get for an input binary(0, 255)
image are:And the possible magnitude values are:
0, 510, 1020, 1530
.0, 360.63, 510, 721.25, 806.38, 1020, 1081.87, 1140.40
So, you'll get different output images from Canny if you use, for example
(minVal, maxVal)
as(200,400)
or(400,600)
.If you use thresholds that are in the same interval (the boundary of the intervals are the magnitude values shown above), then you'll get always the same result.