How to Extract part of Image using Matlab - matlab

i have not used matlab much, i need to extract the part of Left and Right Coronary Arteries of a heart from a given heart image.
this is my image,
based on morphological operations, this is what i have come up with,
f=imread('heart.jpg');
diam=strel('diamond',19);
line=strel('line',10,90);
linef=imclose(f,line);
line120=strel('line',10,120);
line120f= imclose(f,line120);
bothline=linef+line120f;
diamf=imclose(f,diam);
arterybm=diamf-bothline;
binaryartery= im2bw(arterybm,0);
mask=cast(binaryartery,class(f));
redPlane=f(:,:,1);
greenPlane=f(:,:,2);
bluePlane=f(:,:,3);
maskedRed=redPlane.*mask;
maskedGreen=greenPlane.*mask;
maskedBlue=bluePlane.*mask;
maskedRGBImage=cat(3,maskedRed,maskedGreen,maskedBlue);
subplot(2,3,1);imshow(f);title('Input Image');subplot(2,3,2);imshow(diamf);title('imclose with Diamond Mask');subplot(2,3,3);imshow(bothline);title('imclose with Line 120 and 90 mask');subplot(2,3,4);imshow(arterybm);title('Difference of line and diamond');subplot(2,3,5);imshow(binaryartery);title('Convert to binary image');subplot(2,3,6);imshow(maskedRGBImage);title('Apply mask to input image');
is there any better approach ?

This task is quite a difficult one, worth academic article if you find solution working flawlessly in most cases. My suggestion: search for articles on the topic, and also try "Matlab File Exchange" (http://www.mathworks.com/matlabcentral/fileexchange/). If you are very lucky, someone might have already solved this problem and posted a solution.

Have a look at the Frangi filter (aka ridge-detection filter), it is meant to detect blood vessels.
There is an implementation available on the file exchange:
http://www.mathworks.com/matlabcentral/fileexchange/24409-hessian-based-frangi-vesselness-filter

Related

Inner workings of Google's Quick Draw

I'm asking this here because I didn't find anything online.
I would be interested in how Google Quick Draw works, specifically:
1) How does it output the answer - does it have a giant output vector with a probability for each type of drawing?
2) How does it read the data - I see they've implemented some sort of order aware input system, but does that mean that they input positions of the interpolated lines that users draw? This is problematic because it's variable length - how did they solve it?
3) And, finally, which training algorithm are they using? The data grows each time someone draws something new, or do they just feed it into the algorithm when it's created?
If you know any papers on this or by miracle you work at Google and/or can explain how it works, I would be really greatful. :)

Matlab BlobAnalysis (for cell counting)

I have been researching on how to program image processing for counting objects and I found the following homepage about Matlab for cell counting
I am not familiar with Matlab, but found their ideas interesting, so reading this, I see that they are using a BlobAnalysis Object to find the centroid of the segmented cells (You can see the image :
Now, this seem very interesting but I wonder what this operation is doing exactly? (please don't give me the definition written in the docs-"it is finding the property in the blobs". How? is it segmenting it? separating it? ) As far as I can see either you separate the cells first (that is the whole point of counting- I am doing this in other program using watersheding) and then finding the centroids is just something added and not so important, OR somehow this blob analysis is doing some interesting segmentation itself that I would like to know.
Anyone familiar with this can give me some pointers or advice here?

Difference between cvPOSIT and cvFindExtrinsicCameraParams2

Another OpenCV question;
Without me having to implement 2 versions - can anyone enlighten me to what the differences are between cvPOSTIT and cvFindExtrinsicCameraParams2 and maybe the advantages of each.
The inputs and outputs appear to be the same.
From my experience, cvFindExtrinsicCameraParams2() works for coplanar points (so it is probably an implementation of http://dl.acm.org/citation.cfm?id=228149), while cvPOSIT() doesn't. But I am not 100% sure.
It appears that cvPOSIT() only exists in OpenCV's old C API and not in the new C++ API. Conversely, cvFindExtrinsicCameraParams2() is in both. While not a perfect indicator, my best guess is that they both implement the POSIT algorithm with minor modifications and the former exists only for legacy reasons.
Beyond that, your guess is good as mine. If you want a definitive answer, I suggest asking on the OpenCV mailing list.
I've used cvPOSIT already. It only works on 3D non-coplanar points on the object. Because it bases on the algorithm from "DAVIS, D. F. D. A. L. S. 1995. Model-Based Object Pose in 25 Lines of Code". So you will have to find a way around for coplanar features
With cvFindExtrinsicCameraParams2(), it also works on planar features, solve the transformation using cvFindHomography and then refine the result by levenberg-marquardt approximation. For non-coplanar points, the preprocessing is done by a different method DLT (Direct Linear Transformation) (not ".. 25 lines of Code" article anymore)
I'm not pretty sure about thier performance, which one is faster. As I know, ".. 25 lines of code" is very fast, and suitable for realtime vision up to now.

Problem with block matching in matlab

I have written matlab codes for two different block matching algorithms, extensive search and three step search, but i am not sure how i can check whether i am getting the correct results. Is there any standard way to check these or any standard code which i can run and compare my result with.I read somewhere that JM software can be used but i didnt find any way to use it.
You can always use the results produced by your algorithms to create the next frame of video and then analyze its quality by either visually inspecting it (which is rather subjective, and we like to deal in numbers) or calculating the mean square error between the produced image and the one you're trying to estimate. Mean square error of the exhaustive (extensive) search should be lower than the one three-step gives you.
Well, did you try to plot it? I mean,after the block-matching you have a new image, right?.
A way to know if you result if true or not is to check the sum of the difference of 2 frames.
A - pre_frame
B - post_frame
C - Compensated frame
If abs(abs(A-B)) is lower than abs(abs(A-C))) that mean it could be true.
Next time, try to specify your algoritm. Also, put your code here to help you more.

Maximum packing of rectangles in a circle

I work at a nanotech lab where I do silicon wafer dicing. (The wafer saw cuts only parallel lines) We are, of course, trying to maximize the yield of the die we cut. All the of die will be equal size, either rectangular or square, and the die are all cut from a circular wafer. Essentially, I am trying to pack maximum rectangles into a circle.
I have only a pretty basic understanding of MATLAB and an intermediate understanding of calculus. Is there any (relatively) simple way to do this, or am I way over my head?
Go from here, and good luck:
http://en.wikipedia.org/wiki/Knapsack_problem
and get here:
http://www-sop.inria.fr/mascotte/WorkshopScheduling/2Dpacking.pdf
At least you'll have some idea what are you tackling here.
I was fascinated to read your question because I did a project on this for my training as a Mathematics Teacher. I'm also quite pleased to know that it's thought to be an NP-problem, because my project was leading me to the same conclusion.
By use of basic calculus, I calculated the first few 'generations' of rectangles of maximum size, but it gets complex quite quickly.
You can read my project here:
Beckett, R. Parcels of Pi: A curve-packing problem. Bath Spa MEC. 2009.
Pages 1 - 15
Pages 16 - 30
I hope that some of my findings are useful to you or at least interesting. I thought that the application of this idea would most likely be in computer nano technology.
Kind regards.
Packing arbitrary rectangles into a circle to meet a space efficiency objective is a non-convex (NP-Hard) optimization in general. This means there will be no elegant or simple solution that will solve this problem optimally. The solution methods are all going to depend on any specific domain knowledge you can use to prune the search tree or develop heuristics. If you have no experience in this type of problem you should probably consult with an expert.
doesn't this resemble the Gauss's Circle Problem? See
http://mathworld.wolfram.com/GausssCircleProblem.html
or, this can be seen as a "packaging problem"
http://en.wikipedia.org/wiki/Packing_problem#Squares_in_circle