There is a axes named image in which I show the image when the user presses the browse button.
imshow(orgImg, 'Parent', handles.image);
Then I do image processing stuff.
There is a clear button to clear that image shown in image axes after done all the processing.
I used cla(handles.image,'reset');
This clear the image from axes. But, it displays the XTick and YTick as 0, 0.5, 1, 1.5 and so on and also XColor and YColor as black.
I don't want XTick and YTick values to be displayed on axes and also color should be white. But I need to display the axes without above values. Now it shows the axes with above values.
How can I remove those properties?
After you clear the image, issue this command
set(gca,'xtick',[],'ytick',[],'Xcolor','w','Ycolor','w')
you can replace gca with your current handle.
The easiest solution may actually be to leave out the 'reset' argument to CLA:
cla(handles.image);
This will have the effect of clearing the image object from the axes, but leaving the axes settings unchanged (i.e. the axes will still be invisible).
Related
I tried using axes for displaying images in Gui.But, before displaying any images, the axes is shown with a plot figure while running the GUI, something like below.
You can see the default axes being displayed. Is there a way to display the axes in running GUI without displaying these plot figures? So that when the image is not displayed in the axes, nothing is displayed. Thanks in advance.
UPDATE 1
I have used 9 axes here, thus the long trail of y axis.
Yes, you can use
axis off
To remove the axes from the empty plots. Then use
axis on
When you actually plot something to bring them back.
Best,
Here's my problem: I have an axes object in a figure.
The user can draw a bunch of points on the image.
Up to this point, everything is working as it should.
Now the user shall be able to zoom, draw some points on the zoomed image, and revert back to the original image once he/she has done.
I have a function updateVisualization that is called every time there is a change on the axes made by the user.
In this function, I tried to use
zoom(h, 'reset');
imagesc(updated_img);
zoom(h, 'out');
This solution keeps the zoom every the user does a modification :-) however, once the user is done, he/she cannot go back to the original zoom level.
What should I do?
% Saving zoom level
xlim = get(handles.axes, 'XLim');
ylim = get(handles.axes, 'YLim');
% Displaying image
imagesc(im, 'Parent', handles.axes, 'ButtonDownFcn', #axes_ButtonDownFcn);
% Setting saved zoom level.
set(handles.axes, 'XLim', xlim);
set(handles.axes, 'YLim', ylim);
I want to make a Matlab GUI program.
When i use the axes to display the image, there are the axes number around the axes.
How to delete it?
so my GUI program will display the axes without any coordinates around the axes.
here is my code for display an image in axes.
axes(handles.axes16);
handles.image_gray = image_gray;
imshow(image_gray);
guidata(hObject, handles);
And here is the axes coordinates that i meant.
Remember that the axes is an handle object with many properties. I would recommend setting the axes properties 'xtick', and 'ytick', to an empty array. That way, you preserve the border, and background color of the axes. Simply turning the axes off will make your lines render on top of the background figure, which may or may not be the effect you are looking for.
Example:
set(handles.axes16,'xtick',[],'ytick',[])
A quick way to turn off the axis is, well, axis off:
Example
figure;
plot([-10:10],randn(21,1));
xlabel('x');
ylabel('y');
Now turn axis off:
axis off
I want to display an image and allow mouse over to show pixel values- as in impixelinfo function.
The thing is- I show the image on an inverse scale (1./image) but want the shown values to be the original ones.
Is there some way to do it?
A possible workaround - puts your original image over the top as a transparent layer, leaving the visible image (1./image) for the user and an invisible image which impixelinfo takes its data from.
imshow(1./image);
hold on
h = imshow(image);
set(h, 'AlphaData', zeros(size(image)));
impixelinfo
I have a project of "Optical Character Recognition" in MATLAB and i need your help:
how do i recognize when the user press the mouse on an image?
i trying to do this with ButtonDownFcn but even when i just printing message
the message is not printed.
i want to allow the user to select the license plate from the image.
how can i do this and save the Pixels of the selected area?
thanks in advance.
Addressing your two questions:
I'm guessing that you are trying to set the 'ButtonDownFcn' of the figure window, which won't work how you expect it to. If you want to do something when the user clicks on an image, you should make sure that you're setting the 'ButtonDownFcn' of the image, and not the figure window or the axes object. Note this line in the figure property documentation (emphasis added by me):
Executes whenever you press a mouse button while the pointer is in the figure window, but not over a child object (i.e., uicontrol, uipanel, axes, or axes child).
This is why you have to set a 'ButtonDownFcn' for each object you want it to work for. Setting it for the figure window won't make it work automatically for each object in the figure. Here's an example that sets the 'ButtonDownFcn' for the figure and an image object:
img = imread('peppers.png'); %# Load a sample image
hFigure = figure; %# Create a figure window
hImage = image(img); %# Plot an image
set(hFigure,'ButtonDownFcn',... %# Set the ButtonDownFcn for the figure
#(s,e) disp('hello'));
set(hImage,'ButtonDownFcn',... %# Set the ButtonDownFcn for the image
#(s,e) disp('world'));
Notice how clicking inside and outside the image displays a different message, since each calls the 'ButtonDownFcn' for a different object. Notice also that if you click on the tick mark label of one of the axes, nothing is displayed. This is because the axes object has its own 'ButtonDownFcn', which wasn't set to anything.
If you have access to the Image Processing Toolbox you can use the function IMFREEHAND to have the user draw an ROI (region of interest) in the image. Then you can use the createMask method to create a binary mask of the image with ones for pixels inside the ROI and zeroes for pixels outside the ROI.