something like gimp "fuzzy select" in python/PIL - python

I have image with some object at not solid background. I want to extract this objects like in gimp using "fuzzy select". This can be an example:
http://img249.imageshack.us/gal.php?g=25750902.png
Question is what is the best way to do it using python/PIL...

I suppose you would need some flood-fill algorithm (such as breadth-first-traversal) in which you stop exploring pixels with different color than black.
Wikipedia has an excellent explanation with animations and pseudo-code
http://en.wikipedia.org/wiki/Flood_fill

And besides, if you want to add feature like "tolerance" in Photoshop, you should apply this method Connected-component_labeling when getting connected vertex on your graph while doing flood fill

As of today, skimage 0.19 has a flood fill algorithm: link

Related

Display an image with pixel values shown numerically

I'm looking for OpenCV or other Python function that displays a NumPy array as an image like this:
Referenced from this tutorial.
What function creates this kind of grey-scale image with pixel values display?
Is there a color image equivalent?
MATLAB has a function called showPixelValues().
The best way to do this is to search "heat map" or "confusion matrix" rather than image, then there are two good options:
Using matplotlib only, with imshow() and text() as building blocks the solution is actually not that hard, and here are some examples.
Using seaborn which is a data visualisation package and the solution is essentially a one-liner using seaborn.heatmap() as shown in these examples.
My problem was really tunnel vision, coming at it from an image processing mindset, and not thinking about what other communities have a need to display the same thing even if they call it by a different name.

Interpolating blacked out ROI in an image with python

I have been browsing the internet and stack overflow in order to find a solution to my problem, but to no avail.
So here is my problem:
Problem
I have a series of images with specific ROIs, where I detect a signal change. In order to extract the signal I need subtract the background of the image from the actual signal. Unfortunately I can't just subtract the images, as this doesn't delete the background noise sufficiently.
Solution Idea
What I want to do is to cut out (black out) my ROIs and then do an interpolation across the entire "reduced" image. Then I want to fill in the blacked out ROIs again via interpolation. This way I can get an idea of what the background below my signal is actually doing. I have been playing around with griddata, RectBivariateSpline, but I haven't found a way that works.
So far I have been doing this in MATLAB with the function scatteredInterpolant, but I would like to do it in python.
Below an image series, that describes the concept. One can see the third image being slightly blurry in the before blacked out ROIs.
Imageprocessing concept
So, does python provide a solution or way, which is similar to MATLABs scatteredInterpolant or how could I best tackle this problem?
Thank you.

How to remove the shadows from these pictures using python opencv?

How to remove the shadows of the seeds? Also I would like to know if there is a way to change the color of all the seeds to red colour?
It seems rather easy to detect the seeds since your background is homogeneous. You can start by some simple image processing (contrast enhancement, thresholding, contour detection) to detect the seeds and then you can plot red blobs (with the same area as the detected regions) on the original image. As for the shadows, you can check this question (How to remove the shadow in image by using openCV?).
I think you can solve with this paper and it will make you interesting.
The algorithm described there works quite well and this will be a good example for you in using opencv.
And you can find the source code here
Regards.

how to fill inside a region of an image in opencv python?

I have found the boundaries of an image like this:
Now I need to fill inside of the region (it is a breast tissue). Is there any functions in opencv or other modules in python like skimage through which I can do that?? something like maybe imfill in MATLAB.
A simple floodfill will not work in this case. The image you have provided looks like one single contour but it has multiple holes in it. Before you can apply flood fill, I suggest you fill the holes in the line using spline curves. Once done you can apply floodfill.

How to create a flood fill figure animation using python?

How to create flood fill figure animation using python?
I saw this image online and was wondering how to go about these types of animation. I think this is a very useful technique that can be used in maps, presentations, etc and was curious about it.
The image:
http://i.imgur.com/zaSxkLI.gif
I Researched these questions:
Flood Fill in Python
How to flood-fill part of a bitmap enclosed by a black border with my chosen color?
Python: floodfill algorithm for minesweeper
Flood Fill Algorithm Python
Looked at this resource:
http://inventwithpython.com/blog/2011/08/11/recursion-explained-with-the-flood-fill-algorithm-and-zombies-and-cats/
Questions:
Can you point me to working code that does this type of exercise?
Which libraries are considered standard to use now?
How does the logic behind the fill exercise work?
Can you point me to more information/resources (maybe the docs for the libraries)
How could I integrate this concept with matplotlib? Can you point me to an example?
Thank you so much!

Categories

Resources