This question already has answers here:
Set data tips programmatically?
(2 answers)
Closed 7 years ago.
How to show data tip message on a matlab plot programmatically with only a mouse click, and without using Data Cursor, to show custom messages in different positions like the following:
"You can't." From the "Tips" section of the help page for the function datacursormode:
You place data tips only by clicking data objects on graphs. You cannot place them programmatically (by executing code to position a data cursor).
But people do achieve this with hacking, like here. The short version of what they are doing is
h = ezplot('sin(x)')
cursorMode = datacursormode(gcf);
hDatatip = cursorMode.createDatatip(h);
Related
This question already has answers here:
How to set stacked bar chart series color dynamically?
(1 answer)
How do I create and distribute diagonal stripes on a rectangle?
(2 answers)
Closed last month.
How to use fill parttern for the Bar or Stacked Bar graph in Jasper Report?
Can anyone give some instructions or a easy example?
Many thanks.
My expecting is somethink like the graph beblow,and I want to use diagonal stroke to fill the bar.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have an image of Lego bricks which I have segmented in order to get only the blue and red colored bricks.
I also have two templates of bricks that I want to find.
I want to count the number of each of the template bricks in the image. I thought of counting the number of circles on top of the bricks, but some of the bricks are flipped. How could I do this?
Counting the number of circles on top of the bricks could be a very difficult task. A better solution is to look after better properties such like the relation between the hight and the width of the brick.
A possible start for segmentation is as follows:
E = regionprops(L,'all'); % E contains all properties
area = cat(1, E.Area) % saves the area in a variable
cp = cat(1,E.Centroid) % saves the center of the object
figure,imshow(label2rgb(L));
hold on; plot(cp(:,1), cp(:,2), 'b*'); % displays the center of the objects
It will show you your segmentation and will display some information about the properties of the obejects. From there on you will be able to look for what properties you are watching for and can select them in if statements. Depending on your image and your selected properties this could take up to 10 properties but most likely will be around 5.
For further information look here: MATLAB segmentation overview
This question already has answers here:
Render MATLAB figure in memory
(4 answers)
Closed 7 years ago.
I have the following Matlab 2013b code:
subplot(2,2,1);plot(var([c1 c2],0,2)); title('var(c1,c2)');
subplot(2,2,2);plot(var([c3,c4],0,2));title('var(c3,c4)');
saveas(gcf,pth);
I would like to execute this code without opening a figure window in Matlab.
Is this possible? If not, I would like the figure window to be minimized upon plotting.
If you start with a call to figure you can change the visibility:
figure('Visible','Off')
will create an invisible figure window.
The MATLAB documentation on Figure properties also includes this warning:
Changing the Visible property of a figure does not change the Visible property of its child components even though hiding the figure prevents its children from displaying.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I work in my project on the problem of writer recognition from handwritten Arabic documents.
to identify the writer, I used a database image,
My problem is how to extract features from these images. I'm new in matlab and I do not have much knowledge in image processing.
please help me, I need to extract the contour from image and then encode it using freeman chain codes.
The following link contains freeman code in matlab but I do not know how to use it.
I welcome your suggestion and thank you in advance
You can use the imcontour function.
For instance, if you load this sample image
Img = imread('test.png');
You can get the contour with the command:
C = imcontour(Img, 1);
Then you can use the freeman function you cite with C as the first input.
Another example could be to use bwperim. This essentially takes a look at all of the distinct binary objects in an image and extracts the perimeter of each object. This only works for objects that are white, and so using #Crazy rat's example, we can thus do:
im = ~im2bw(imread('http://i.stack.imgur.com/p9BZl.png'));
out = ~bwperim(im);
The above will read in the image and convert it into binary / logical. Next, we need to invert the image so that the object / text is white while the background is black. After, call bwperim so that you extract the perimeter of the objects, and then to convert back so that the object text is black, we re-invert.
The output I get is:
The distinct advantage with bwperim over imcontour is that bwperim provides the actual output image whereas imcontour only draws a figure for you. You can certainly extract the image data from the figure, like using the h = gcf; out = h.cdata; idiom, but this will include some of the figure background in the result. I suspect you would like the actual raw image instead, and so I would recommend using bwperim.
How do we use this with the Freeman code you linked?
If you look at the source code, it takes in two inputs:
b, which is a N x 2 matrix of coordinates that determine the boundary of the shape you want to encode
unwrap - An optional parameter
If you want to use the function that you have linked us to, simply extract the row and column coordinates of those pixels that are along the boundary of your image. As such, this is another limitation of imcontour, as you won't be able to determine these locations without the raw contour image itself. Therefore, all you really have to do is:
[y,x] = find(out == 0);
cc = chaincode([y x]);
This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
Printing a MATLAB plot in exact dimensions on paper
How do I save a plotted image and maintain the original image size in MATLAB?
I have recently been trying to create a custom-sized graph in MATLAB and save it automatically using the saveas function. In particular, I am having issues saving the files in the size that I create them. Roughly speaking, my code is as follows:
mygraph = figure('Position',[1,20,1280,1024]);
% creates a figure positioned 1 px from the left of the screen
% 20 px from the bottom of the screen
% that is 1280 px in length and 1024 px in height
% some code to create graph
saveas(mygraph,'mygraphfilename','emf')
% saves figure as mygraphfilename.emf.
So far, my code works fine in that it can create a custom sized graph on my screen, but it seems to save the pictures themselves in a default size. The weird thing is that if I do not use the saveas function and save the figure manually, then the image retains its size.
For clarification purposes, I'm currently saving the graphs as emf, though I'm also open to using jpg/png/bmp if works fine too.
Try setting the following:
set(mygraph, 'PaperPositionMode','auto') %# WYSIWYG
print -dmeta -r0 file.emf