image-morphology

Image Erosion manual implementation not doing anything Python

我是研究僧i 提交于 2021-02-11 12:20:05
问题 Testing image I write a Python script that manually do a Erosion Morphological Operation to an image using the attached test image, but when I display both the original and altered image, this last one still looks the same even thought is it supposed to be eroded. I have 3 functions, my Main function, a RGB to Gray Conversion function and the Erosion function. import cv2 import math import numpy as np from PIL import Image, ImageFilter def main(): #Read image img = cv2.imread('pattern04.bmp')

How do i separate overlapping cards from each other using python opencv?

醉酒当歌 提交于 2020-07-20 07:19:28
问题 I am trying to detect playing cards and transform them to get a bird's eye view of the card using python opencv. My code works fine for simple cases but I didn't stop at the simple cases and want to try out more complex ones. I'm having problems finding correct contours for cards.Here's an attached image where I am trying to detect cards and draw contours: My Code: path1 = "F:\\ComputerVisionPrograms\\images\\cards4.jpeg" g = cv2.imread(path1,0) img = cv2.imread(path1) edge = cv2.Canny(g,50

How to find shortest path in skeletonized maze image?

混江龙づ霸主 提交于 2020-06-24 12:55:36
问题 I am working on maze solving using Image Processing and NetworkX search algroithm and need to find the shortest connecting path between two points on those lines. #Solving Maze Using Image Processing and NetWorkx search #Open Maze image img = cv2.imread("C:/Users/Dell/HandMadeMaze1.jpg") kernel = np.ones((1,1),np.uint8) #Convert to GrayScaledImage grayscaled = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) #BınaryThreshold + OtsuThreshold + BinaryThreshold retval, threshold = cv2.threshold(grayscaled,

Preserving “connectedness” of lines in an image with OpenCV

↘锁芯ラ 提交于 2020-05-16 08:57:06
问题 I'm working on a handwritten digit recognition problem, using OpenCV for preprocessing and Keras/Tensorflow for inference. I'm having an issue with losing certain features in the pre-processing which roughly consists of: Otsu Threshold Dilation (to get the digit thickness to be the same as another dataset that I have used to pre-train my neural network) Downsizing to 28x28 pixels using cv2.INTER_AREA (again to match the pre-training data) Here's an example of feature loss: That's meant to be

Why is the structuring element asymmetric in OpenCV?

99封情书 提交于 2020-02-21 05:22:48
问题 Why is the structuring element asymmetric in OpenCV? cv2.getStructuringElement(cv2.MORPH_ELLIPSE, ksize=(4,4)) returns array([[0, 0, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], dtype=uint8) Why isn't it array([[0, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [0, 1, 1, 0]], dtype=uint8) instead? Odd-sized structuring elements are also asymmetric with respect to 90-degree rotations: array([[0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0]], dtype=uint8) What's

Why is the structuring element asymmetric in OpenCV?

£可爱£侵袭症+ 提交于 2020-02-21 05:21:33
问题 Why is the structuring element asymmetric in OpenCV? cv2.getStructuringElement(cv2.MORPH_ELLIPSE, ksize=(4,4)) returns array([[0, 0, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]], dtype=uint8) Why isn't it array([[0, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [0, 1, 1, 0]], dtype=uint8) instead? Odd-sized structuring elements are also asymmetric with respect to 90-degree rotations: array([[0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0]], dtype=uint8) What's

General approach for extracting specific lines or line segments in an image

拥有回忆 提交于 2020-01-02 08:13:10
问题 I have this sample cropped image: I need to make black thick lines (horizontal and vertical) disappear or extracted while leave all other info intact. These specific lines are either 4 or 5 pixels thick. I tried: Simple filtering of rows having more zeros/ones if image is read as NumPy array but the filtering condition doesn't terminate till a single row is left with zero or one. Erosion with simple kernel (3,3) but it leaves some noise because some symbols are also thick black Dilation with

General approach for extracting specific lines or line segments in an image

你。 提交于 2020-01-02 08:13:08
问题 I have this sample cropped image: I need to make black thick lines (horizontal and vertical) disappear or extracted while leave all other info intact. These specific lines are either 4 or 5 pixels thick. I tried: Simple filtering of rows having more zeros/ones if image is read as NumPy array but the filtering condition doesn't terminate till a single row is left with zero or one. Erosion with simple kernel (3,3) but it leaves some noise because some symbols are also thick black Dilation with

OpenCV - Is there an implementation of marker based reconstruction in opencv

こ雲淡風輕ζ 提交于 2019-12-23 20:35:58
问题 Morphological reconstruction by opening is similar to basic morphological opening. However in contrast, reconstruction uses two images: a “seed” image, which specifies the values that spread, and a “mask” image. Skimage has an implementation of it here http://scikit-image.org/docs/dev/api/skimage.morphology.html#skimage.morphology.reconstruction Matlab has an implementation which is explained very well here. https://www.mathworks.com/tagteam/64199_91822v00_eddins_final.pdf There is a

Segment out those objects that have holes in it

会有一股神秘感。 提交于 2019-12-23 12:37:09
问题 I have a binary image, that has circles and squares in it. imA = imread('blocks1.png'); A = im2bw(imA); figure,imshow(A);title('Input Image - Blocks'); imBinInv = ~A; figure(2); imshow(imBinInv); title('Inverted Binarized Original Image'); Some circles and squares have small holes in them based on which, I have to generate an image which has only those circles and squares that have holes/missing point in them. How can I code that? PURPOSE: Later on, using regionprops in MATLAB, I will extract