How do you create a marker on a 2D image that is plotted using imagesc()? Is it even possible?
You simply want to draw something over your image? Then you can just use hold on.
For example, this will draw a circle at the 10,10 pixel of the image.
imagesc(magic(24));
hold on
scatter(10,10);
Related
How to plot a figure like this
The data is like f(x_i,t_j), i=1,2,..,M, j=1,2,...,N. The horizontal axis is time t and vertical axis is space x
I know that mesh gives a 3-D plot and surf also gives 3-D surface, I wonder which command can give the above 2-D figure?
To make a 2D heatmap, display your array as an image using imshow, and add a colorbar.
I calculate the rectangular bounding box coordinates for objects in my matlab code ([xmin ymin width height]). But the coordinates might not be precise. Then, I want to draw the box on the image and modify that by dragging the box and/or adjusting the borders. I tried to use imrect and imcrop, but those functions do not draw the draggable/adjustable rectangle on image, based on predefined coordinates. Is there any way to do that?
Thanks in advance for your time.
Take a look at imrect. It works much like the imcrop rectangle but you can set an initial position and get the current position by calling getPosition.
I'm trying to draw an arrow on top of an image in MATLAB, between two pixels: [x0,y0] and [x1,y1].
I tried to use annotation function. The problem is that the function takes as an input x,y values which represent coordinates on the figure, instead of on the image itself.
Does anyone knows how can I draw an arrow between two pixels in an image?
Example
imshow(imread('peppers.png'));hold on;
I would like to generate a blue arrow from pixel (1,1) to pixel(200,200), so it should look something like this (only in blue instead of black):
Thanks!
you could simply use the quiver-function:
figure;
imshow(imread('peppers.png'));hold on;
quiver(0,0,200,200,0)
I would like to place a mask (image) on a moving object that is extracted using blob analysis.
frame = insertObjectAnnotation(frame, 'rectangle', bboxes, labels);
I found an example in matlab documentation. here bbox is the cordinates of moving object. its drawing rectangles around the moving objects in the video using inserObjectAnnotation() function.
like that I want to place a filled in shape in place of rectangle. how can I do that?
Please help
The insertShape function can draw filled shapes into images.
I have x and y coordinates of a contour. Now they cannot be used as pixel locations since they are not integers. I am unable to find a way to convert them into pixel locations. Floor and round functions do not help as they create blobs. I need a crisp contour similar as in a plot.
You can plot your (x,y) points, remove axis ticks, and grab the axes into image. Try this:
figure;
plot(rand(10,1),rand(10,1));
box on; set(gca,'XTick',[],'YTick',[])
F = getframe(gca);
Image = F.cdata;
figure; imshow( Image );
EDIT:
If you need to draw many lines on image you may consider Bresenham's line algorithm to draw lines on image. See, for exmple, question and suggestions there:
How to draw a line on an image in matlab?
MATLAB: Drawing a line over a black and white image