Cleaning image and identifying brain parts from tomography opencv2 - python

I have an assignment to do which is given a tomography image i have to remove anything but the brain and also find the left and right hemisphere of the brain by painting or extracting them.
Examples of tomography
tomography1
tomography2
Any ideas??

I will post my reply here even though is more like a comment (I don't have enough points to comment on posts).
Are you obliged to use Python and OpenCV?
Why don't you use Freesurfer? I work with MRI images but it makes all the steps you cited automatically using reconall function.
https://surfer.nmr.mgh.harvard.edu/fswiki/recon-all
https://andysbrainbook.readthedocs.io/en/latest/FreeSurfer/FS_ShortCourse/FS_03_ReconAll.html

Related

Image Processing in Python- Is there a general solution to this problem?

I have been going over this for days now and have hit a road block as I am too scared to try out my hypothesis.
I would like to find out the number of grayed rectangular boxes in this image. However, I am not sure how I can do that. I was thinking of two ways:
i. Getting area of the connected components, calculating their median and getting the number of components between a certain percentile of the area (may sound pretty strange).
ii. Making a machine learning model and find out the similar boxes in the image and count them.
However, I would like them to be more generalized so that I will need to be able to make the solution fit other images that I would need to be processed.
Here is my source Image:
Any sort of help/suggestions and even solutions would be greatly appreciated.
Thanks in advance!
Maybe you are losing a lot of image information with filtering...Do you have an unfiltered source image too? I suppose ML approach would work pretty nice then.
I noticed you could achieve better resolution if your camera is 90 rotated (If you could affect this)

Opencv remove ghosting distortion

I get a problem when handling images taken from cell phones.
Image sample:
So, get ghosting especially for the question number area.
I think the reason is a little joggle when press the shutter.
Is there any way to remove the ghosting thus question number area will look more clear?
There is another worse one:
Actually, I find some image denoising functions like cv2.fastNlMeansDenoisingColored(), and it indeed works well upon some images.
Unfortunately, doesn't work for the above two images.
Env: Python3.6.5 Opencv:3.4.0
Thanks.
Wesley

Rotating and cropping a ROI from minAreaRect() OpenCV python

I'm trying to make a program that rotates and crops an image ROI (without losing a single pixel of the frame) based just on what minAreaRect() returns (from seeing what it can mark with drawContours).
Now since I don't understand what the function returns other than the rotation angle(list [0:1]) I'm struggling to make that myself. All I found on the internet was a Stack Overflow question with code that wasn't really explained very well and didn't realy work (atleast for openCV 3.6 not)
May I have any clues to what is the return syntax of this function and what is the method and keywords to search for such things, as well as a short little function that can maybe do that rotation and cropping? Since that looks like a quite common and simple thing to achieve.

Crop Facebook and Instagram photos from page screenshots

So I have quite an interesting image segmentation problem. Here, I have scraped instagram photos which are stacked vertically.
see image here(too long to post): https://imgur.com/a/gPr2J
What I am trying to do is quite simple. I just want to extract each post image from the screenshot, and save it to some directory. I am trying to find ways to make this work, like cropping by pixel color at a certain height but none of it is working perfectly.
Any method that would quickly segment this image. Python BTW.
I think you should start with segmenting each post out. Use the gaps between each post (which are always uniform) to segment each post out.
Then approach capturing the image inside the post - breaking this down into 2 different problems will make your algorithm simpler in my opinion.
I have a few ideas, not entirely sure how will they work for you, but thought they might give you some leads to try out:
1) All these instagram images seems to have a "heart" shaped icon just below the image you want to extract. Maybe figuring out detecting the heart shape might be good idea? Once you have found the "heart" you can look for the image just above it. Since it is a UI, my hope is that all the images that you want to extract will be a fixed number of pixels above the "heart". Moreover, they should also have the same height and width, I think.
2) Another possible idea is to find the edges in the image. Again, the images you want to extract seem to have a strong edge with respect to their background (but so does text and other UI elements). However, these edges should ideally have the largest area (which is also mostly fixed) enclosed between them. So, after finding the edges, you can use the find contours in function in opencv and then filter out the contours which have an area greater than a threshold. Have you tried something like this?

How to find a fix number of (almost) fixed proportion rectangles with opencv?

I am writing a simple fly tracking software and I would love some input from opencv experts.
The image I have looks pretty much like:
I used to do tracking using kmeans and PIL/numpy but I re-wrote everything to use blob detection in opencv. Tracking works OK but I would also like to automatize division of ROI.
What I need to do is find each of the 32 grooves that appear in the picture, where flies live. See the black rectangle on the image as example of what I mean.
I think cornerHarris may be what I need but how do I specify only the grooves and not each single rectangle found in the image? All those grooves have proportions of roughly 10:1.
Thanks!
I don't think cvCornerHarris is even close to what you need.
A much better start would be to experiment with the demo available at: OpenCV-2.3.0/samples/cpp/squares.cpp. This technique uses Canny(), dilate() and findCountour().
Right out of the box, this demo outputs:
I believe that with a few tweaks here and there you can have your party started.

Categories