I'm trying to analyse the area of a self-similar set in MATLAB. The full image is shown on the LHS below. When zooming in, one can see that MATLAB only renders the image to the scale shown in the centre image. On the RHS below is the resolution when I zoom in on the Matlab figure rather than the printed bitmap - it shows this detail that I want to render, but is not rendered when I print the figure.
I've made the plot with the viscircles function. As a side note, I'd also like to fill in the circles.
I'm using print to save save the plot as a bitmap. I've tried:
Increasing the resolution of the file I'm saving with print, but that doesn't appear to render the image in more detail but merely save the resolution-limited image with more pixels.
Increasing the size of the figure on the screen in the hope of trying to make it render the whole thing. I can't seem to make the image bigger than my monitor. Would suppressing the output of the image help?
A different approach: taking the coordinates that I was passing to viscircles and then drawing circles around them without using a MATLAB plot function. This required a loop for the 10^6 particles in my simulation and was very slow whereas the viscircles approach only took a day - I think it does plot all circles at once.
Firstly, many apologies if this question has been posted/asked/answered (let me know the link if that is the case).
How do I capture the HOG values displayed/plotted on the visualisation figure in Matlab?For example in this link (Matlab) https://uk.mathworks.com/help/vision/ref/extracthogfeatures.html
img = imread('cameraman.tif');
[featureVector,hogVisualization] = extractHOGFeatures(img);
%Plot HOG features on the original image
figure;
imshow(img);
hold on;
plot(hogVisualization);
What I don't understand is when I open 'hogVisualization' in matlab the values which are plotted in the image don't make sense. Where can I find the values plotted on the original image?
To be more specific, here is what I'm trying to do. In this image here > phase I'm trying to detect the lines in the red region (I can detect these lines). However, as you can see these lines are disconnected in the blue region. In my algorithm, I need to track which direction I should go (e.g. to the left, right or to a certain angle direction) when it reaches the disconnected line.
For this purpose, I used HOG to find the orientation. Visually, I can see the correct orientation when I visualise it, which can be used to connect two disconnected lines within the blue region. But the problem is I need to find the values plotted in the image. How do I get these values? I can see them visualised on the image but I can't retrieve the actual numerical values.
Thanks,
Erick
I have a big plot in MATLAB (4095 points total) and I want to export this figure as a high res image which can be zoomed in just like the original figure can be zoomed in. Below I attached two images, one is full size plot and the second one was exported separately by zooming in the figure and then exporting. 1st image gets pixelated (obviously) when I zoom in. So my question is if it is possible to export the figure as an image (any format but .fig) that can be zoomed in for more granular detail.
You need to save the figure using a vector format, such as pdf, ps or eps.
For example: try
plot(sin(0:.001:2*pi)) %// example graph
The resulting figure is:
Then print to pdf:
print -dpdf example %// Or change -dpdf to -deps, -depsc, -dps, -dpsc
Now open the generated file, example.pdf. You can zoom on it and you won't see it pixelated. Here's an example of the top of the sinusoid at 6400% zoom.
I have searched the internet for a solution to the question above but have had no luck up to now. I have been producing a number of 2D plots where the origin of (0,0 point) is represented by an image. I have made these by plotting the data on an image, where the image is all white apart from the desired symbol at the center point (so I can reshape it as needed). I then move the axis so they cross at the center point. This all works fine, but I now have to create a number of plots using ‘fill’ to place two shaded areas on the plot that overlap in the center. This causes the symbol to be difficult to see even using ‘alpha’.
I therefore have two options to get the desired effect, both requiring me to put an image on top of the figure after the data is plotted. These options are:
1) I place the image on top of the plot and apply alpha to it (May not look very good as it will mute the plot).
2) The better option would be to crop the image around the symbol and then position it on top of the plot so the image center is at the origin (I have no idea how to position the image this way).
Both methods need the image to be placed on top of the plot after the data is plotted. I have tried 'hold on' and calling 'figure(imagesc(Image))' neither work. I have Matlab 2012b but no toolboxes (so cannot use subimage etc.)
Thanks for any help you can give
You can set the transparency of individual pixels of an image using the 'AlphaData' option. So, you can plot the overlay as follows:
% plot your data normally
...
hold on
% assuming the overlay is a 11x11 image
image(-5:5,-5:5,image_matrix,'AlphaData',alpha_matrix);
image_matrix would obviously be the matrix with your image data stored in it, while alpha_matrix would be a matrix of the same size as image_matrix. Every pixel you want to show would have a value of 1, every pixel you want to hide (the white pixels) would be 0.
Assume that the data X has size 1000 *1000. X is displayed using the command:
imagesc(X);
and all the rows are labeld using:
set(gca, 'YTickLabel', somelabels);
Although the data X are properly polotted and the Ytick labels are also shown, the labels are highly overlapped because of the large number of rows. Is there any way to solve the problem? Any help will be highly appreciated.
Edit 1
I realize my question was not stated well to represent my problem. I am going to wrap up my understanding based on the answers and re-ask a question:
To show as many rows/labels in a Figure Window, the following helps:
set(gca,'FontSize',6),
or, alternate the distance (suggested by yuk),
or, set(gca,'YTick',1:10:1000,'YTickLabel',somelabels(1:10:1000));
The code
set(gca,'Units','pixels','Position',[20 20 10000 10000]);
will display a zoomed-in image by default. But if the zoomed-in image is too large to fit in the Figure Window, only part of the image will be displayed. However, neither zoom out nor the pan tool can reach to the rest part of that image.
The default behavior of the code
imagesc(X);
set(gca, 'ytick', 1:1000, 'yticklabe', ylabel);
displays the whole image fitting to the Figure Window with overlapping labels. Nevertheless, it does allow one to zoom into part of the image and to see the un-overlapped labels.
If I save the image into a pdf file:
imagesc(X);
set(gca, 'ytick', 1:1000, 'yticklabe', ylabel);
saveas(gcf, 'fig.pdf');
Then the saved pdf is only the image fit to the Figure Window with overlapping labels. However, unlike zoom in within Matlab figure window, zoom in within a pdf reader won't change the relative position/distance of labels. As a result, the zoomed-in image in pdf is still label-overlaped.
So my question is:
How to save the image into a pdf file or png such that it has a similar behavior as of point 3 above when opened in Adobe reader, rather than that of point 4?
You can also play with axes label font to make it smaller.
set(gca,'FontSize',6)
See also other axes properties to change font - FontName, FontWidth, FontUnits, etc.
Another solution: If your labels are short, you can alternate there distance from the axes, so the labels will not overlap. Check this example:
lbl = cellstr(reshape(sprintf('%3d',1:100),3,100)');
lbl(1:2:100) = strcat(lbl(1:2:100),{' '});
imagesc(rand(100))
set(gca,'ytick',1:100)
set(gca,'yticklabel',lbl)
Part of the resulted image:
UPDATE
To answer your updated question.
PDF document can contain only static images. Once you saved the figure to PDF (or any other graphic file), you cannot zoom in/out as with MATLAB figure tools.
You can zoom first on the MATLAB figure, then save PDF file. In this case the figure will be saved as is. But this way assumes user interactivity with the figure.
If you know your region of interest in advance, you can set axes limits with XLim/YLim properties, then save the figure.
Example:
imagesc(X);
set(gca, 'ytick', 1:1000, 'yticklabe', ylabel);
set(gca, 'XLim',[1 20], 'YLim', [20 40])
saveas(gcf, 'fig.pdf');
By the way, you can also save figure to file with PRINT function. More flexible. SAVEAS is just wrapper around it.
print('-dpdf','fig.pdf')
Another option is to rotate the tick labels which is discussed in this technical solution. You can find a number of easy-to-use implementations on the MATLAB File Exchange.