How to remove entries in masks using Python and Image processing? - python

I'm currently working with masks of lung CTs.
The example shown below is an example of a mask. I would like to remove the entry in the image, a kind of an edge hole. How can I do this using Python/OpenCV or something else?

Related

OCR: Retrieve essential parts of original image after noise reduction with Python

I'm trying to denoise an image (photographed text) in order to improve OCR. I'm using Python - skimage for the task, but I'm open to other library recommendations (PIL, cv2, ...)
Example image (should read "i5"):
I used skimage.morphology.erosion and skimage.morphology.remove_small_objects quite successfully, resulting in :
The noise is gone, but so is some part of the 5 and dot on the i.
Now the question: I had an idea how to repair the 5. I add the original image to the denoised one, resulting in parts being black, and parts being gray:
Then I make all gray parts connected to black parts black (propagate over the structure). Finally, by erasing all parts which are still gray, I get a clean image.
But I don't know how to do the propagate part using one of the above libraries. Is there an algorithm for that ?
Bonus question: How can I preserve the dot on the i ?

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.

Opencv Blur just within Circle

How does one blur a circular portion of an image in the python bindings of Open CV. Can one apply blurring on images without making new images?
It doesn't look like the OpenCV's blurring and filtering functions allow masking the input. I suggest applying the filter on a Rect around the circular portion, then assign the elements of the blurred sub matrix to the original image while masking the elements that do not correspond to the circle.

image segmentation using pil/any package of python

i need to segment an image into regions .i'm using pil.i found no module to segment image in pil. I need this segmented regions as a list or dictionary.
Actually i'm trying to compare the images for similarity in content aware fashion.for that i need to segment the image. i tried segwin tool but it is drawing another image(which is not required and also time consuming)
thans in advance
The easiest way to segment an image into regions is creating an other image called labelmap. The "region 1" is represented by all the 1 valued pixels within the labelmap, and so on. If you need the pixels of the "region 3" you just binarize the labelmap with a thershold equal to 3 and multiply the result with the original image.
Like Oliver I advise WrapItk.
For this task i prefer numpy and scipy. In terms of image processing these two have all you need. For array math i recommend numexpr. Take a look at http://docs.scipy.org/doc/scipy/reference/ndimage.html
Take a look at the PIL Handbook, you can use the "crop" function to get a subregion of the image.
You might want to try the python bindings for ITK, a segmentation tool in C++.

Categories

Resources