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

GUI input pixel range from inputdlg

Asked by Swarup on 22 Aug 2014
Latest activity Commented on by Swarup on 26 Aug 2014 at 8:11

Hi Everyone, can anyone help?

1) I am making a GUI for image segmentation.

2)In my GUI, I ask for a input number and display the respective slice. I use inputdlg command.

3)In the second step. I have to select few pixel coordinates and concate them together (please see example). These pixel ranges have to be 'hand picked' using the data cursor from the displayed image. And feed in to another input dilog box which is generated using inputdlg command.

   example :
X1=A(326:345,106:113);
AA = (X1(:);X2(:).....)

3) The problem is, in the second step, I cannot use data cursor to retrieve pixel coordinates from the displayed image.

if true
  % code
 AA = getappdata(handles.select_call, 'AA');
   prompt = {'Enter slice no. for training'};
   dlg_title = 'Input';
   num_lines = 1;
   def = {'1'};
    answer = inputdlg(prompt,dlg_title,num_lines,def);
    numbr= str2double(answer);
   A = AA(:,:,numbr);
        size(A);
        axes(handles.axes7);
       imagesc(A); axis equal; color all; title('slice no. for traning');
     x = inputdlg({'X1','X2','X3','X4','X5','X6','X7'},...
    'pixel range from image.format',[1 20; 1 20;1 20; 1 20; 1 20; 1 20; 1 20]);
     data = str2double(x);
data
  end

Best wishes, Swarup

3 Comments

Adam on 22 Aug 2014

Sorry, I'm not quite sure what the question is. There are too many additional bits required for me to just paste your code into my Matlab, but without that I'm not sure which part of your code is causing a problem and what that problem is.

Are you getting an error message or just not the result you want or something else?

Swarup on 24 Aug 2014 at 12:54

Hi Adam,

I am not getting an error message. The code runs fine. I need a trick, to collect pixel coordinates and feed it in to a dilog box.

The GUI first asks for an image slice and displays it. Then asks for pixel coordinates. By the time pixel coordinate window pop out. I cannot access the image. (i.e I can see the image in the axes window but cannot use the data cursor to extract pixel coordinates.)

I hope its clear. feel free to ask again if you don't understand.

Regards, Swarup

Geoff Hayes on 24 Aug 2014 at 13:31

Swarup - where is your code to get the pixel coordinates? You state I have to select few pixel coordinates and concate them together (please see example). Is this the

 x = inputdlg({'X1','X2','X3','X4','X5','X6','X7'},...
    'pixel range from image.format',[1 20; 1 20;1 20; 1 20; 1 20; 1 20; 1 20]);

So an input dialog appears with 7 edit fields that you want to be populated by the user or the user using a data cursor? If the latter why pop up the dialog asking the user for input?

Swarup

1 Answer

Answer by Image Analyst on 24 Aug 2014 at 14:50
Accepted answer

Why not simply use rbbox() or imrect() to let the user select the rectangle in your image?

1 Comment

Swarup on 26 Aug 2014 at 8:11

Dear Mr Analyst and Goeff,

The use of function rbbox(), imrect() and ginput() serves my purpose to collect data coordinates. Although as Goeff hinted, I have to write a code to collect data and concate them together.

http://www.matlabtutorials.com/howto/rbbox

provides insight to approach it.

Thanks guys,

Regards, Swarup

Image Analyst

Contact us