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

What the error in this code..?

Asked by Lalit Patil on 20 Dec 2012
      N = 7;
     for m=1:N
    rgb = imread(fname(m,:));
    cdata = ginput;
    data(:,:,m) = cdata(1:4,:);


For this seven images i want data where i will click.

But when i am executing this code, it shows only cursor on image but not allowing to click.. Why..?

If any mistake then tell me..?


Walter Roberson on 20 Dec 2012

Try using


instead of imshow(rgb)

Lalit Patil on 20 Dec 2012

Thank you..

And also cdata = ginput(4)

Lalit Patil on 20 Dec 2012

when i am clicking on image it is just a click and i can not see where actual i have clicked, so i want to put a mark of '+' sign at there where i click.. So, what will be the modification in code.?

Lalit Patil


No products are associated with this question.

1 Answer

Answer by Walter Roberson on 20 Dec 2012
Accepted answer

Consider using roipoly()

Alternately, only ginput() one value at a time, and text() a '+' into place at the returned coordinates before going on to the next.


Lalit Patil on 20 Dec 2012

I will do ginput(4) so there will be four values.. Now when i clicking to extract this values at that time '+' point should be placed at clicked place in image so i can see how exactly i have clicked... I am clicking at corner of chessboard..

And what you have explained i can't understand..

So, i want to modify code..

Walter Roberson on 20 Dec 2012
for K = 1 : 4
  thispoint = ginput(1);
  text(thispoint(1), thispoint(2), '+');
  points(K,:) = thispoint;
Walter Roberson

Contact us