.
I have been using ImageJ to process images, but now I would like to have my workflow entirely in Python, if possible.
Until now I found everything I need using OpenCV, except one thing: ImageJ has a really nice number of thresholding methods which I don't see available in Python (as far as I know).
According to the documentation (here and here), there are a few thresholding methods available in OpenCV. In particular for my images I need the 'intermodes' method.
In a previous question it was mentioned that 'it is usually pretty simple to implement other Threshold Methods using OpenCV'
are you aware of more thresholding methods than the ones listed above for OpenCV or in Python in general?
if not, how would you go about to implement the 'intermodes' method in Python? Just port the original (MATLAB) code to python?
Any suggestions are welcome. Thanks
.
1. Other Thresholding
OpenCV also has Otsu Thresholding which looks somewhat similar to intermodes
Other Methods are available in scikit-image
2. Making your own
Yes, you just define a function that does the thresholding for you. Make sure to vectorize appropriately with numpy
Related
So I have been asked to motion deblur a frame captured from a video, I am kind of new to this deblur filters so need help. The video does not contain any noise, just a vertical motion blur. I am not allowed to use skimage, or any other library except cv2. It would be a great help even if what technique or function I have to use comes to know. Thanks!
You can use the Motion Deblur Filter of opencv, if you specifically want to use opencv.
Following is the link to its documentation, which is fairly easy to understand:
http://amroamroamro.github.io/mexopencv/opencv/weiner_deconvolution_demo_gui.html
You can go for skimage as well. It has many function like deconvolution which can help in deblurring images.
I think that for this kind of problem you have to use the recent deep learning techniques. They outperform the classical approaches. I recommend to look on github for a repository that would already provide a trained network that can deblur the same kind of blur that you have.
I never tried it, but this could be a nice candidate.
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 StackOverflow post from year 2015 linked underneath which suggested a fairly good algorithm to address this issue. It has been two years since and I was wondering if a better implementation was released for opencv or if anyone has a better solution for the same.
Morphological Reconstruction in OpenCV
I would prefer to not mix 2 libraries (opencv and skimage) and am trying to find if there is an opencv method to do morphological reconstruction. I am not looking for ready to consume code any pointers are appreciated.
I want to detect symmetries (rotation, translation, etc) of a simple figure or a shape in a image. That is, if I find one symmetry I want to replicate my original figure with it.
Are there any function or module?
I have thought in python-opencv, but I did not find nothing.
Let me just throw some packages at you: OpenCV for Python Cookbook might be a good start. A search for "opencv" on the Python Package Index yields several bindings of OpenCV for Python.
Concerning the detection of symmetries: The answer to question how to detect simple geometric shapes using OpenCV? might be a good start. After you find similar objects, check their orientation. Replacing then should be a piece of cake.
I'm looking in to learning about processing and handling images with Python. I'm experimenting with searching the inside of an image for a specific picture. For example, this picture has two images in it that are the same;
In Python, how would I go about detecting which two images are the same?
I would recommend you to take a look at OpenCV and PIL, if you want to implement simple (or complex) algorithms on your own.
Furthermore you can integrate OpenCV with PIL and also numpy, which makes it a really powerful tool for this kind of jobs.
I've tried looking around and have been unable to find any implementation of either Otsu's method or a median filter into Python other than OpenCV.These are the only two links of documentation for the OpenCV functions that I've tried.
http://opencv.willowgarage.com/documentation/c/image_filtering.html
http://www.cs.indiana.edu/cgi-pub/oleykin/website/OpenCVHelp/ref/OpenCVRef_Cv.htm#decl_cvThreshold3
I checked this post first but it never really seemed to have a full solution that fits my problem.
Machine vision in Python
I'm basically looking to see if anyone knows any other functions that I can implement both Otsu's method and a median filter. I'm just trying to find alternatives before I have to program them into myself, but I would rather not have to reinvent the wheel unless necessary. Thanks for your help in advance, if you need some more specific information just let me know.
In response to the Otsu Method I was able to find an image processing packaged called Mahotas that contained it. All I had to do was easy_install it. The documentation can be found here.
http://packages.python.org/mahotas/index.html?highlight=otsu#mahotas.otsu
I am not sure about Otsu's method but the Scipy library has a whole sub-library dedicated to image processing. For example here is the link to their multi-dimensional median filter:
http://docs.scipy.org/doc/scipy-0.9.0/reference/generated/scipy.ndimage.filters.median_filter.html#scipy.ndimage.filters.median_filter
The matlab image toolbox includes a built in median filter.
http://www.mathworks.com/help/toolbox/images/ref/medfilt2.html
If you don't have the image processing toolbox, you can implement one using block processing.