如何显示图像大小以保持原始矩阵的大小

发布于 2025-01-28 05:17:07 字数 597 浏览 1 评论 0原文

数据是一个512-BY-512矩阵,由imagesc可视化,但原始的512By-512尺寸无法保存,并且图像大小只能保存为800 x 800通过设置以下内容。

data = rand(512,512);
x = [0 0];
y = [512 512];
figure('position',[200,200,512,512]);
% image(log10(data(1:64,1:64)),'CDataMapping','scaled');
% figure;
imagesc(x,y,log10(data));
axis image;
axis off 
axis equal
axis square
truesize([512 512])
% set(gca,'XTick',[])
% set(gca,'YTick',[])
set (gcf,'Position',[100,100,512,512]);
% truesize(fig,[512 512]);
set(gca,'Position',[0 0 1 1])
axis normal;
saveas(gca,strcat('tumor','.jpg'))
print -djpeg99 'foo.jpg'

data is a 512-by-512 matrix, visualized by imagesc, but the original 512-by-512 size cannot be saved, and the image size can only be saved as 800-by-800 by setting the following.

data = rand(512,512);
x = [0 0];
y = [512 512];
figure('position',[200,200,512,512]);
% image(log10(data(1:64,1:64)),'CDataMapping','scaled');
% figure;
imagesc(x,y,log10(data));
axis image;
axis off 
axis equal
axis square
truesize([512 512])
% set(gca,'XTick',[])
% set(gca,'YTick',[])
set (gcf,'Position',[100,100,512,512]);
% truesize(fig,[512 512]);
set(gca,'Position',[0 0 1 1])
axis normal;
saveas(gca,strcat('tumor','.jpg'))
print -djpeg99 'foo.jpg'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随风而去 2025-02-04 05:17:07

imwrite将您输入的数据用作数据像素值生成指定大小的图像。

这是512 by-512灰度图像的一个示例:

data = rand(512, 512);
imwrite(data, 'foo.jpg');

如果要产生颜色图像,则需要输入3通道矩阵,例如imwrite(rand(512,512,3),' bar.jpg')

(颜色)编码在文档中另有指定。

imwrite uses the data you input as the pixel values to generate an image of the specified size.

This is an example of a 512-by-512 grayscale image:

data = rand(512, 512);
imwrite(data, 'foo.jpg');

If you want to produce a colour image, you need to input a 3-channel matrix, for example imwrite(rand(512, 512, 3), 'bar.jpg').

The (colour) encoding is otherwise specified in the documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文