为什么这个图像 - 使用Colormap显示不能在Matlab中工作? [英] Why this imagesc-imshow with Colormap not Working in Matlab?

查看:1371
本文介绍了为什么这个图像 - 使用Colormap显示不能在Matlab中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑并在答案中展开滑块,关于同时显示/加入两个图像Matlab的滑块,可以通过在Matlab 2016a中使用.mat数据来更改色彩映射。
因此,我必须使用 imagesc 因为你可以改变色彩映射。
我想从包含变量时间潜在和<$ c的.mat数据制作图像$ c>矩阵这样我就可以更改colormap / etc

I am considering and expanding the slider here in the answer about To show/join Two Images Simultaneously in Matlab's slider with the capability of changing the colormap by using .mat data in Matlab 2016a. Therefore, I have to use imagesc because there you can alter the colormap. I want to make the images from .mat data containing the variables time, potential and matrix such that I can change colormap/etc

for k=1:2
   % loaded variables from .mat data
   img=imagesc(time, potential, matrix); 
   colormap('jet')
   signal=cat(2,signal,img);
end

windowWidth = 320;
hImg = imshow(signal(:,1:1 + windowWidth,:), ... % TODO complication here?
    'InitialMagnification', 100, 'Border', 'tight');

% End of the video code here https://stackoverflow.com/a/35924614/54964
% Not necessary for the case here!

最后,我想用 imshow
输出

At the end, I want to do the magnification with imshow. Output

Index exceeds matrix dimensions.

Error in masi (line 7)
hImg = imshow(signal(:,1:1 + windowWidth,:), ...



代码2与imagesc-write-imshow



我找不到办法做图片c -imshow没有以.png和.png图像结果写入光盘。
所以只有 saveas imread 这里

for k=1:2
   % loaded variables from .mat data
   imagesc(time, potential, matrix); 
   colormap('jet');

   saveas(gcf,'/tmp/Figure','png');
   imgRGB=imread(fullfile('/tmp/','Figure.png'));

   signal=cat(2,signal,imgRGB);
end

windowWidth = 320;
hImg = imshow(signal(:,1:1 + windowWidth,:), ... 
    'InitialMagnification', 100, 'Border', 'tight');

通过书写和阅读提供正确的输出。

which gives the correct output by writing and reading.

我正在试验Suever的总答案解析度。我发现默认图像结果有噪音,您可以在滑块视频中轻松看到。
我认为最好的分辨率是-r95。我知道信号具有95%灵敏度的指标,所以我直接选择它。测量中存在大约5-15%的不确定性,因此-r85也可能是好的,但我现在还不能很好地评估它。
我的系统中的低分界线是r55,没有生成图像(OS X 13Macbook Air)。
一些分辨率值和我的经验

I am experimenting Suever's answer for total resolution. I find the default image result noisy which you can easily see in slider-video. I think the best resolution is -r95. I know that the signal has indicators with 95% sensitivity so I selected it directly. There are uncertainties about 5-15% in the measurement so -r85 could be also good but I cannot evaluate it right now enough well. Low boundary is r55 for the resolution in my system without generation of the image (OS X 13" Macbook Air). Some resolution values and my experience

GUI中的> r124错误,表示某些上边界

Error with >r124 in GUI, which indicates some upper boundary

Struct contents reference from a non-struct array object.

Error in matlab.graphics.internal.getframeWithDecorations (line 49)
x = bi.getWidth();

Error in alternateGetframe

Error in getframe (line 84)
  x = alternateGetframe(parentFig, h, offsetRect, withinClientRect);

Error in masi (line 114)
    writeVideo(vid, getframe());

能够估计r85,r90和r95之间的分辨率是非常好的当输入信号的不确定度为5-15%时,我不会从原始的1D信号中分阶段丢失它。

It would be very nice to be able estimate the quality of resolution between r85, r90 and r95 when uncertainty of the input signal is 5-15% such that I would not lose it in stages from my original 1D signal.

我得到了奇怪的结果,发现 [0 0 15 15] 是具有大输出图像,小鬼影和无边界伪影的最佳选择。
我尝试了一些数学因素,如sqrt(2)和pi失败。
每英寸的默认点数与前者相同,但图像的尺寸约为两倍。

I got strange results and found that [0 0 15 15] is the best selection with big output image, little ghosts and no boundary artifacts. I tried some mathematical factors like sqrt(2) and pi unsuccessfully. The default points per inches is like the former but with about two times smaller image.

如何使用<$ c显示 imagesc 的结果$ c> imshow 放大倍数?

How can show the result of imagesc using imshow with magnification?

推荐答案

基本想法似乎是你要创造一个RGB图像,它是使用 imagesc 而不是实际将其首先保存到磁盘的屏幕上显示的版本。有几个完成此任务。

The basic idea seems to be that you want to create an RGB image that is a version of what is displayed on your screen using imagesc without actually saving it to disk first. There are a couple of accomplish this.

getframe

有可能使用 getframe 。这将返回一个包含两个字段的结构: cdata colormap cdata 字段是您指定的数字的RGB表示形式(如果未指定,则为 gcf )。 / p>

It is possible to grab a simple screenshot of the current axes using getframe. This will return a structure that has two fields: cdata and colormap. The cdata field is an RGB representation of the figure you specify (or gcf if you don't specify).

fr = getframe(hfig);
rgbImage = fr.cdata;

这种方法的缺点是 getframe <的输出分辨率/ code>只是图形的大小(以像素为单位)。如果您在小屏幕上显示非常大的图像,显​​然会在结果图像中丢失很多细节。

The downside of this approach is that the resolution of the output of getframe is simply the size of the figure (in pixels). If you are displaying a very large image on a small screen, you are obviously going to lose a lot of detail in the resulting image.

打印

内置的 print 功能通常用于将信息发送到打印机或图像文件;但是您可以将输出设备指定为 -RGBImage 这将返回RGB版本作为输出。

The built-in print function is typically used to send information to a printer or image file; however you can specify the output device to be -RGBImage and this will return an RGB version as the output.

rgbImage = print(hfig, '-RGBImage');

使用 print 的真正好处是您可以控制输出图像的分辨率以及其他因素的数量。

The real benefit of using print is that you can control the resolution of the output image as well as a number of other factors.

biggerRGB = print(hfig, '-RGBImage', '-r300');  % 300 dpi

如果在创建图形时,您一定要指定尺寸(以英寸为单位) ),此操作的结果将是相同的大小,无论您当时使用的是什么机器。

If, when you create your figure, you are sure to specify the size (in inches), the result of this operation will be the same size regardless of what machine you may be using at the time.

hfig = figure('Units', 'inches', 'Position', [0 0 10 10]);

使用此结合上面的 -r300 ,结果总是为3000x3000像素。

Using this combined with the -r300 above, the result will always be 3000x3000 pixels.

这篇关于为什么这个图像 - 使用Colormap显示不能在Matlab中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆