openCV defect detection problem(How to make the borders neat?) - python

I want to detect dust in the circle in the image, but there is a problem in that the edges are detected even in areas that are not actually defective. I am curious to see if it helps to handle the border part.
I would like to know how to clean up the pixels of the partial parts.

Related

Edge detection Gray image

i need some advice in a computer vision projekt that i am working on. I am trying to extract a corner in the image below. The edge im searching for is marked yellow in the right image. The edge detection is always failing because the edge is too blurred in the middle.
I run this process with opencv and python.
I started to remove the white dots with a threshold method. After that a big median blur (31-53). After that a adaptive Threshod method to seperate the areas left and right from the corners. But the sepearation is always bad because the edge is barely visible.
Is there some other way to extract this edge or do i have to try with a better camera?
Thanks for your help.
First do you have other dataset? because it is hard to discuss it just from 1 input.
Couple things that you can do.
The best is you change the camera of imaging technique to have a better and clear edge.
When it is hard to do so. Try model-based fitting.If you image is repeatable in all class. I can observe some circles on the right and 2 sharp straight-line edges on the left. Your wanted red soft edge circle is in the middle of those 2 apparent features. That can be considered as a model. then you can always use some other technique for the pixel in-between those 2 region(because they are easy to detect) . Those technique includes but not limit to histogram equalization, high pass filter or even wavelet transform.
The Wost way is to use parameter fitting to do. What you want to segment is sth not a strong edge and sth not a smooth plane. So you can tweak the canny edge detect to find those edge which is not so strong. I do not support this method. If you really no choice and no other image, then you can try it.
Last way is to use deep learning based method to train and auto segment this part out. This method might work. but it needs you to have hundred if not thousands of dataset and labels.
Regards
Shenghai Yuan

clustering pixels to create a solid shape

I am working on a script that detects the bottom of a cooking pot, given a picture from above at a slightly slanted angle. This is a tough task due to lighting, lack of edges, and the glare of the metal pot.
This is a sample image I am working with:
image
img = cv2.imread('img.jpg')
gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
The bottom of the pot is visible, but hard to detect.
So far, I was able to produce this image using:
th2 = cv2.adaptiveThreshold(gray_img,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2)
And this image using:
edges = cv2.Canny(img,30,60)
The solution seems intuitive since in both images the base can be detected easily, but I am not able to figure out the implementation.
My intuition tells me that I should cluster white pixels starting from the center of the image, and line the border of the segmentation generated from the clustering. I am not quite sure about how to go about that. Any advice would be greatly appreciated.
WORK IN PROGRESS
What is your overall goal? Do you want to detect something at the bottom? Count bubbles or something like that? Or you you want to check for defects?.
As you already mentioned, it's hard because of the reflections, so you could start using less direct light and maybe use a diffuse source.
No single light bulb, no direct sun, maybe use a white canvas. Or span a thin piece of white cloth between the current light source and the camera.

Tricky Edge Detection

i am learning opencv for a project and i need to detect edges on a very bad image. I want to mark the edge between the light gray and the dark gray area.(marked yellow) My problem is to find the right combination of operators to do this job.
So far i tried simple thresholding, but the gray-value on the right circle goes from 30 to 100 which is found everywhere else in the image. The image is also very noisy and filters (median,gaussian) are not very useful. I am also familiar with Sobel-Edge Detection but the wanted egde is not big enough to sort out the edges that are made from the noise.
I also tried the Canny-Operator but even this operator detects many edges on the right side of the image because of the many white and black pixels.
Someone an idea?

Automatic ROI/rectangle recognition

I want to be able to pass on multiple images to python and detect the contour of the object in the picture. The pictures all represent money bills, hence the ROI is always going to be rectangular. Whatever ive tried, im not able to exactly detect the money bill.
I tried canny edge detection but the transparent regions on the money bill (canadian money)example of a canadian bill make it hard to detect the whole bill. Does anyone have any suggestions on how to automatically crop out just the money bill? Thanks in advance!
It is an easy matter to binarize the image, as the background is perfectly white. Use a threshold level as close as possible to white, to reduce the effect of the shadow, bottom right.
Then after connected component labelling, the convex hull gives you a nice crop polygon.
If you prefer a quadrilateral, you can pick the extreme vertices in the four cardinal directions.

How can I use PIL to crop a select area based on face detection?

Hi I am wanting to use the python imaging library to crop images to a specific size for a website. I have a problem, these images are meant to show people's faces so I need to automatically crop based on them.
I know face detection is a difficult concept so I'm thinking of using the face.com API http://developers.face.com/tools/#faces/detect which is fine for what I want to do.
I'm just a little stuck on how I would use this data to crop a select area based on the majority of faces.
Can anybody help?
Joe
There is a library for python that have a concept of smart-cropping that among other options, can use face detection to do a smarter cropping.
It uses opencv under the hood, but you are isolated from it.
https://github.com/globocom/thumbor
If you have some rectangle that you want to excise from an image, here's what I might try first:
(optional) If the image is large, do a rough square crop centered on the face with dimensions sqrt(2) larger than the longer edge (if rectangular). Worst-case (45° rotation), it will still grab everything important.
Rotate based on the face orientation (something like rough_crop.rotate(math.degrees(math.atan(ydiff/xdiff)), trig is fun)
Do a final crop. If you did the initial crop, the face should be centered, otherwise you'll have to transform (rotate) all your old coordinates to the new image (more trig!).

Categories