MATLAB Answers


Error in my Code , it didnt produce correct result

Asked by Maria
on 21 Jul 2013

If i've an image like : How can i identify the major two arcs in that image .

If the arcs can be modeled by y=(ax)^1/2 +b where a and b are constants such that a∈[250,400] and b∈[0,50] where b is an integer number as it represents the y-intercept of the arc in the image.

Output should be a 2-pixel thicker version of the detected arcs over the original image

May this will done by Hough Transform

Any Demo for doing that !please


The approach with ginput() is one of the simplest possible, because it bypasses the quite complicated development of an algorithm for detecting/extracting curves from the image.

Have you tried what I told you above? Now take one set of coordinates and inject x and y in the equation that you give in your question. What do you see? Doesn't it look like an equation with two unknowns, a and b? Now repeat the operation for another set of coordinates .. it seems that you have another equation with the same two unknowns, right? So you have two equations with two unknowns a and b, and a bunch of constrains on their values. This should be enough for your to get an approximate result already, without it to involve more than basic algebra.

the deadline for this probllem by thursday , thats why i need it before thursday ,,

Cedric Wannaz ur approach refused by my supervisor ! he need it to be done as i ask before with a full question specification , i'm not specialist in matlab to do all of this ! !

i'm trying to modify my code alot of times but i cant get the result ! i'm sleepless ! if u want to help me the last time , plzz do it for me ..

I already spent way too much time explaining why you should learn MATLAB before trying to undertake this kind of quite complex problems, giving extra information and a simpler alternative (simpler than the fully algorithmic approach). I also told you that you should ask a more specific question (than "please solve my complicated problem for me and provide me with complete code that I can give to my supervisor"). I suggested "how to use hough transforms in MATLAB for extracting parametric curves (e.g. parabola)", which would already be quite complex in itself.. and unlikely to be fully answered on the forum. This would have been a chunk of the answer, which is way more complex as there is a grid (which might vary a bit between images), multiple curves, etc.

As I said above, it is unlikely that anybody will spend time to explain all the material to you, or to provide you with full code. Either your supervisor knows you but doesn't know the material and is asking for way too much, or you are missing a significant amount of practice (math + programming + scientific computing + image processing + MATLAB basics) for working for this person. In either case, it is not up to us to work half a day for providing a full solution to him or to you.

1 Answer

Answer by Image Analyst
on 22 Jul 2013
 Accepted answer

Just filter out the grid points - they seem to be at fixed positions so it will be very easy to find them but just summing vertically and horizontally and look for high sums

verticalProfile = sum(grayImage, 2);
horizontalProfile = sum(grayImage, 1);
gridLocations = verticalProfile > 50; % or whatever.
grayImage(gridLocations, :) = 0; % Make those rows black.

etc. doing the same for the vertical grid lines.....

Then you have just the curves. Find each one and use polyfit() or whatever.


any full demo for doing that plz ...

i'm yrying this code , it's nearly give me 70% of correct result ., i'm do my best to get a correct result but i cant , can u make any simple modification to my code for get correct result , i think this condition play major role in my problem ((( arcs can be modeled by y=(ax)^1/2 +b where a and b are constants such that a∈[250,400] and b∈[0,50))) ,please image analyst :

I = imread('para.gif') ;
[R,C] = meshgrid(30:30:300, 1:15:300) ;
I(sub2ind(size(I), R(:), C(:))) = 0 ;
[R,C] = meshgrid(1:7:300, [10 42 74 106 138 171 203 235 267 300]) ;
I(sub2ind(size(I), R(:), C(:))) = 0 ;
BW = edge(I,'canny');

[H,T,R] = hough(BW);

P = houghpeaks(H,5,'threshold',ceil(0.3*max(H(:))));

x = T(P(:,2));

 y = R(P(:,1));lines = houghlines(BW,T,R,P,'FillGap',5,'MinLength',7);



hold on

max_len = 0;

for k = 1:length(lines)

xy = [lines(k).point1; lines(k).point2];






Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!