问题描述
我在python中检测Canny边缘时遇到问题。 我的起始图片是我在帖子中添加的普通账单图片。 我可以用Canny检测到边缘,没有任何问题,但是我想知道最长的检测到的边缘在图片中。
这里是input image 这是output image。
现在,我想知道输出图像中最长的边缘,以剪切掉图片中不必要的部分,但是我不知道如何...
我的代码:
# Read reference image
#refFilename = RefRefFileCalculation(row)
refFilename = "C:\\Maturaprojekt\\Test 1\\30Zeilen.JPG"
print("Reading reference image : ",refFilename)
imReference = cv2.imread(refFilename,cv2.IMREAD_COLOR)
# Read image to be aligned
imFilename = save_path
print("Reading image to align : ",imFilename);
im = cv2.imread(imFilename,cv2.IMREAD_COLOR)
print("Aligning images ...")
# Registered image will be resotred in imReg.
# The estimated homography will be stored in h.
imReg,h = alignImages(im,imReference)
# Write aligned image to disk.
outFilename = "C:\\Maturaprojekt\\Test 1\\gedreht\\" + sample_names[i]
print("Saving aligned image : ",outFilename);
cv2.imwrite(outFilename,imReg)
# Load the image file
image = cv2.imread(save_path)
# Check if image was loaded improperly and exit if so
if image is None:
sys.exit('Failed to load image')
# Detect edges in the image. The parameters control the thresholds
edges = cv2.Canny(image,100,700,apertureSize=5)
# display the output in a window
cv2.imwrite("C:\\Maturaprojekt\\Edge Detection Test 1\\cropped\\" + sample_names[i],edges)
i = i+1
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)