I have some pictures like this:
enter image description here
After choosing the contour that I want by index by the function cv2.findContours: enter image description here
I want to remove the nearly white background outside this contour. I tried this method: Removing background color from image opencv python but I don't know how to modify the mask such that the inner area of the contour is white and the outer is back.
Could anyone tell me how? Thanks in advance
Related
Currently, I am doing Image COLOUR filtering operation second MEDIAN filtering then CANNY EDGE DETECTION ALGORITHM.
Then, I read pixels using for loop and I draw lines using pixel, but I do not getting proper result for palm scanning and showing lines on human Palm.
So if anybody has any types of idea regarding this then please let me know.
Currently i am getting this type of result:
but I need this type of output:
Oh I got your problem, You can do this by following steps.
1.process your hand image with canny edge detection algo lets name that cannyImage.
2.now create the bitmap of cannyImage and remove black pixels from the image and replace them with transparent pixels, black only because canny image will be filled with black color and objects lines in white when you process the image through the algo, now you have extracted the image with palm lines white in color, lets name that palmLineImage.
3.now the main part is MASKING you need to mask the palmLineImage on the original image.
These three steps will give you your desire O/P.
Tools you can use GPUImage awsesome library by BradLarson for this https://github.com/BradLarson/GPUImage2
For refining the palm image from background which I'm sure you have to use in future you can use GrabCut algo
LINK - https://github.com/naver/grabcutios
and now the apple has launched Photos captured in Portrait Mode on iOS 12 contain an embedded person segmentation matte that made it easy to create creative visual effects like background replacement.
Links - https://developer.apple.com/videos/play/wwdc2019/260/ , https://developer.apple.com/videos/play/wwdc2019/225/
Looks like you need to use something like the douglas peucker algorithm - to simplify the number of data points and smooth the lines. link - https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
I just start exploring computer-vision field and I'm trying to create something like this (this image is what I'm trying to achieve not what I've already achieve)
My approach is (just a logical solution, havent try it yet):
Color detection.
First, get pixel position of lines with red and green color then add all that value to arrayRed and arrayGreen.
Segmentation
Get base image from cache then get all pixel with value that close to arrayRed and label it as label background. Do the same for arrayGreen
Convert color space to RGBA and set the Alpha of label background to 0
My question :
Am I on the right path?
Is this possible to achieve with OpenCV library?
If my approach is wrong, what's the efficient and actually right approach(in pseudo-code or python) to achieve the goal?
I am struggling with the fuzzy selection tool in gimp - try to make the dark part in the picture black while retaining the dark parts below the light border - any advice how to achieve that?
Not with the fuzzy selection or the color selection :)
Very often the best way is to use the image itself (or a copy). If I understand you, you want to select the top dark part (which is many shades of grey), but not the bottom one. In practice we want an image where the selected parts are white and the un-selected are black, so
duplicate the layer
Color>Desaturate (if the image has colors)
Color>Invert
Filters>Blur>Gaussian blur (around 12px in the image you show). In Gimp 2.10, the median blur can also give interesting results)
Use Threshold to make the white very white and the black very. Use the threshold value that keeps a continuous black line across the picture
Bucket fill the lower white part with black (in Gimp 2.10.10 you can use the new Fill by line art detection option of the bucket
Open the Channels list, right click on any f the R, G or B channels and Channel to selection.
Back to the Layers list, hide or delete the work layer, and select the initial layer to continue.
Using the selection with the Curves tool to set the black and white points on the top part:
I have a .tiff video file with growing fibers that look like the image below
Now
imagine that this fiber will constantly grow and shrink in a straight line. Now I'd like to somehow crop out the region of the video that contains just the fiber with, for example, a black background image.
Now when I play the video I'd like to just see the growing fiber region of the video with the black background everywhere else.
Question: Is there a way to preform a "custom" crop of irregular shaped objects in ImageJ?
If you don't know if ImageJ can do this sort of image processing any other software options are welcome.
Thanks for any help
Yes, you can do this in ImageJ. If you can find a threshold method that captures your fiber, you can turn that into a selection (ROI), and then Clear Outside to turn everything else black:
Image > Adjust > Threshold and choose the threshold, or use one of the automatic methods. But don't apply the threshold!
Edit > Selection > Create Selection (turns the thresholded area into an ROI)
Edit > Clear Outside (makes the background black -- assuming you have set your background color to black)
If you want to make the window smaller, you can do Image > Crop with the selection active. This will crop the image to the rectangular bounding box of the ROI. But this size will vary according to the size of the fiber. So you might want to do this when the fiber is at its largest.
I will have scanned images with gray toned handwriting on white background.
What is the elegant way of selecting, and getting pixels of gray level(non-white) contigous areas?
Which image processing library should i use?
So far i research for a class and method in Leptonica, but found method names like: seedfill, i do not want to fill the area i want to get pixel coordinates that make the contigous area.
So can you also share class name with library name?
Thanks for reading and possible response.
You could use OpenCV. Maybe the findContours function is what you want.