Hi, I was wondering if anyone would know how to export an image that has had a hold on it and a Plot. I'll explain.
I have an image where I detect the contour and what I want to save is the original image where the points that are blue contours overlapping the original image are shown.
clear all; clc; close all
I = rgb2gray(imread('tumor_091R.tif'));
BW = edge(I,'Canny',100/255);
[r,c] = find(BW == 1);
figure
imshow(I)
hold on
plot(c,r,'.')
exportgraphics(gcf,'11.tif')
When I'm in Matlab and I zoom in on a certain area what I get is this:
But when I export it using the exportgraphics command what I get when I zoom in on the area I want to see is a spot of the type I show:
What I want to achieve is that the image I export allows me to zoom in as Matlab does, I tried the getframe option but the result was the same. Thanks in advance

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 20 日
編集済み: Ameer Hamza 2020 年 5 月 20 日

1 投票

If you want to zoom on the image, than you may try to save it in a vector format, e.g., eps file format. Try this
clear all; clc; close all
I = rgb2gray(imread('tumor_091R.tif'));
BW = edge(I,'Canny',100/255);
[r,c] = find(BW == 1);
fig = figure;
imshow(I)
hold on
plot(c,r,'.')
fig.Renderer = 'painters'; % render the points as vector
exportgraphics(gcf,'11.eps')
Alternatively, you can also use this excellent FEX package to save in high-res raster format: https://www.mathworks.com/matlabcentral/fileexchange/23629-export_fig
clear all; clc; close all
I = rgb2gray(imread('tumor_091R.tif'));
BW = edge(I,'Canny',100/255);
[r,c] = find(BW == 1);
fig = figure;
imshow(I)
hold on
plot(c,r,'.')
export_fig(gcf,'11.tif', '-r500'); % 500 is PPI of the image

7 件のコメント

Alejandro Fernández
Alejandro Fernández 2020 年 5 月 21 日
Hi, it worked, the only thing the dots still look huge when I zoom in, but I guess the only way to fix it is to change the markersize to a smaller size or can you think of some other way?
So the result is not exactly what I would have liked to get...
Ameer Hamza
Ameer Hamza 2020 年 5 月 21 日
Does this also happen in the eps format? This seems like a limitation of MATLAB's rasterization algorithm, and decreasing marker size will not be of much help.
Alejandro Fernández
Alejandro Fernández 2020 年 5 月 21 日
Yes, it's the same if I use .eps ...
Ameer Hamza
Ameer Hamza 2020 年 5 月 21 日
Can you try it by increasing the resolution in export_fig
export_fig(gcf,'11.tif', '-r1000');
If this too does not work, then it probably not possible to get a better quality in the exported file.
Alejandro Fernández
Alejandro Fernández 2020 年 5 月 21 日
It still doesn't work but that's okay, I still thank you very much for all your help.
Ameer Hamza
Ameer Hamza 2020 年 5 月 21 日
If possible, you may try to install R2018b and try to export eps in that version. I have already noticed that saving a complex graphic in vector format have greatly degraded after that version. That is why I keep an installation of R2018b just for this purpose. If this is extremely important, you may give it a try, although I am not sure that it will still work. It is just a guess.
Alejandro Fernández
Alejandro Fernández 2020 年 5 月 22 日
I'm sorry it took me a while to answer you, I tried to do it with the 2018b version but nothing, I'm afraid the result is still the same.
Thank you very much for everything anyway.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePrinting and Saving についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by