Preview webcam in axis - disappear my x and y axis - matlab

I want to plot a webcam in MATLAB app designer by preview in axis, but when i do it my x axis and y axis are gone.
how i can plot with showing x axis and y axis.
This is my code :
app.img = webcam;
app.frame = snapshot(app.img);
app.im = image(app.Main_image, zeros(size(app.frame),'uint8'));
axis(app.Main_image,'image');
preview(app.img,app.im);
images:
before , after
the preview is working, i just blocked the camera.
Thank you.

i couldnt reproduce your code.
you could just add following line to your code to make axis visible :
ax=gca();
ax.Visible='on';

Related

How to rotate the axis labels in Google image chart

I want to rotate x axis labels according to attached screenshot, But i am not finding any solution in google image chart.
Also how to put the label on top of the y axis, see the attached screenshot.
This screenshot the x axis labels rotate in approx 60 deg
In this Image the x axis labels appears in vertical format
How to put the query for axis rotation in
chart.apis.google.com/chart link
Thanks,

plotting is displayed upside down at MATLAB GUI

I am working on video surveillance on crowd density estimation. I am implementing a corner detection method for this project. However, I have a problem when my code is combined in GUI MATLAB, the display of plotting corner is upside down and it is not overlay on the original image. Here my code on plotting the image in GUI Matlab.
The problem is solved already and here is the correct code:
% Find row,col coords.
[r,c] = find(cim2);
%After getting row and column coordinate, I plot them together in the original image which is
% overlay image and plotting
imshow(inFrame, 'Parent', handles.axes8);
hold on;
p1 = plot([c],[r],'r.');
set(p1, 'Parent', handles.axes8);
Thank you for #Lokesh for his suggestion.
The explanation of your problem is very well given by floris.But here due to lack of full your code we are not able to perform it on our system. you can aslo try for
axis ij
which is some what similar to above answer. you can also try the below code.
imshow(inFrame,'Parent',handles.axes8);
hold on;
p1 = plot([c],[r],'r.');
set(p1,'Parent',handles.axes8);
hope this works for you..let me know about the result..
imshow inverts the Y axis. Conventionally, in image display the top left corner of the screen is (0,0) with i (the first coordinate) running down the screen, and j (the second coordinate) from left to right.
If you want the image axis to look like a conventional plot axis you can do
axis xy
This will "invert" your image, putting 0,0 in the bottom left.

Change 3D view in matlab

I would like to change the view of a 3D plot in matlab such that the y-axis points upward and the z-axis points to left. For example, consider the following plot:
Here the x-axis points forward, the y-axis points to the right and the z-axis points upward.
I would like to have the y-axis points upward and the z-axis points to the left instead. I tried to rotate the plot (using the figure window toolbar rotate button) but I could not get it to work. (It should just be a simple 90 degrees rotation about the x-axis)
Code to generate the plot:
membrane
view(100,50)
xlabel('x-axis');
ylabel('y-axis');
zlabel('z-axis');
grid on
Try using view. I don't have MATLAB available so I can't test it, but I think it can do what you want.
Example from the documentation:
Set the view along the y-axis, with the x-axis extending horizontally
and the z-axis extending vertically in the figure.
view([0 0]);
EDIT:
Try using three inputs to the view function. I can't experiment myself, but you should be able to do it if you choose the right values here.
From documentation:
view([x,y,z]) sets the view direction to the Cartesian coordinates x,
y, and z. The magnitude of (x,y,z) is ignored.
EDIT 2:
Check out camroll. I think camroll(90) (possibly in combination with view) will work.
From documentation:
camroll(dtheta) rotates the camera around the camera viewing axis by
the amounts specified in dtheta (in degrees). The viewing axis is the
line passing through the camera position and the camera target.
This was posted a while ago, but in case someone else is looking for ways to set y-axis as the vertical one here is a possible fix.
Manually: In the command window type cameratoolbar('show') which will open an interactive toolbar in your plot from which you could change the view. One of the options is to set a principle axis to x, y, or z.
Or in you script you could use cameratoolbar('SetCoordSys',coordsys) command which sets the principal axis of the camera motion. coordsys can be: x, y, z, or none.
http://uk.mathworks.com/help/matlab/ref/cameratoolbar.html

How do I edit the axes of an image in MATLAB to reverse the direction?

I would like to edit the axes in my series of images being displayed.
This is what my image looks like:
As you can see, it ranges from 0 to about 500 from top to bottom. Can I invert that?
Plus, I want to mirror the image being shown, so that it starts from left to right... or, if it's possible, to let the axes show from right to left.
To reverse an axis, you can set the 'XDir' or 'YDir' property of the current axes to 'reverse':
set(gca,'XDir','reverse'); %# This flips the x axis
Keep in mind that flipping an axis in this way flips everything in the plot as well. This probably isn't what you want to do for the y axis. You probably just want to flip the y axis labels, which you can do by modifying the 'YTickLabel' property in the following way:
yLimits = get(gca,'YLim'); %# Get the y axis limits
yTicks = yLimits(2)-get(gca,'YTick'); %# Get the y axis tick values and
%# subtract them from the upper limit
set(gca,'YTickLabel',num2str(yTicks.')); %'# Convert the tick values to strings
%# and update the y axis labels
Im = imread('onion.png');
Im = flipdim(Im ,1); % vertical flip the image.
axis xy; %set the xy to be at (0,0), this flips the image back again.
And whoop dee doo the image now have an y axis with the range from bottom to top!
How can I reverse the y-axis when I use the IMAGE or IMAGESC function to display an image in MATLAB? Another solution from mathworks
I found gnovice's answer helpful but it needed some tweaks for me. I think the following is a more general way to reverse the labels on the y axis. Simply sort the y tick numbers in descending order and relabel.
yTicks = get(gca,'YTick');
yTicks_reverse = sort(yTicks,2,'descend');
set(gca,'YTickLabel',num2str(yTicks_reverse.'));
I was redirected here from a duplicate question:
Flipping axis ticks
What 'ale' wanted to do there was just to flip the y-axis direction to be top down. If that is the only thing needed and nothing else, I would use:
axis ij

Crossing axis and labels in matlab

I just can't find it. How to set up axis and labels in matlab so they cross at zero point, with the labels just below the axis not on left/bottom of the plot ?
If I didn't make myself clear - I just want the plot to look like like we all used to draw it when in school. Axes crossing, 4 quadrants, labels right below axis, curve ... as it goes.
Anyone knows how to set it up ?
You should check out two submissions on The MathWorks File Exchange:
PlotAxisAtOrigin by Shanrong Zhang
axescenter by Matt Fig
Hopefully these will work with whatever MATLAB version you have (the submission from Matt Fig is the most recently updated one).
As of Matlab release R2015b, this can be achieved with the axis property XAxisLocation and YAxisLocation being set to origin.
In other words,
x = linspace(-5,5);
y = sin(x);
plot(x,y)
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
Example is taken from MATLAB official documentation:
Display Axis Lines through Origin
Controlling Axis Location