Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab:颜色贴图颜色不反映图例_Matlab_Heatmap_Gaussian_Gaussianblur - Fatal编程技术网

Matlab:颜色贴图颜色不反映图例

Matlab:颜色贴图颜色不反映图例,matlab,heatmap,gaussian,gaussianblur,Matlab,Heatmap,Gaussian,Gaussianblur,我能够用Matlab拍摄一张图像并在上面覆盖一张热图 我遇到的问题是,图例上的颜色编码与地图上显示的值不匹配 如果在1512x1080图像上运行下面的代码,您会注意到代码中使用的值与图例中指定的值不对应 例如,当考虑像素位置700400中的点时,人们期望显示红色,因为其对应值为0.3。然而,在生成的图像中,该点的颜色为蓝黄色 这是为什么?我如何纠正它 代码如下: %Import an image*********************************************** %As

我能够用Matlab拍摄一张图像并在上面覆盖一张热图

我遇到的问题是,图例上的颜色编码与地图上显示的值不匹配

如果在1512x1080图像上运行下面的代码,您会注意到代码中使用的值与图例中指定的值不对应

例如,当考虑像素位置700400中的点时,人们期望显示红色,因为其对应值为0.3。然而,在生成的图像中,该点的颜色为蓝黄色

这是为什么?我如何纠正它

代码如下:

%Import an image***********************************************
%Ask a user to import the image they want 
%**************************************************************

%The commented out line will not show the file type when prompted to select
%an image
%[fn,pn] = uigetfile({'*.TIFF,*.jpg,*.JPG,*.jpeg,*.bmp','Image files'}, 'Select an image');

%This line will select any file type, want to restrict in future
[fn,pn] = uigetfile({'*.*','Image files'}, 'Select an image');
importedImage = imread(fullfile(pn,fn));


%Setting up the color map to use
ax = gca;
load('MyColormaps','mycmap');
colormap(ax,mycmap);


%Create size for heat map**************************************
%Setting the size for the map, see comments below
%**************************************************************

%What if I wanted an arbitrary dimension
%Or better yet, get the dimensions from the imported file
heatMap = zeros(1080,1512);


%Manually placing the heatmap values along a grid
%Want to set zones for this, maybe plot out in excel and use the cells to
%define the image size?
heatMap(84,328) = .38;
heatMap(132,385) = .42;
heatMap(86,418) = .40;
heatMap(405,340) = .60;
heatMap(263,515) = .35;
heatMap(480,627) = .40;
heatMap(673,800) = .28;
heatMap(598,892) = .38;
heatMap(540,1020) = .33;
heatMap(684,1145) = .38;
heatMap(275,912) = .44;
heatMap(185,798) = .54;
heatMap(700,400) = .3; %This is a testing point, not an actual value


%Generate the Map**********************************************
%Making the density and heat map
%**************************************************************
%Testing different filtering types
gaussiankernel = fspecial('gaussian', [350 350], 25);
%gaussiankernel = fspecial('average', [50 50]);

density = imfilter(heatMap, gaussiankernel, 'replicate');

%imshow(density, []);
oMask = heatmap_overlay(importedImage, density);
set(figure(1), 'Position', [0 0 1512 1080]);
imshow(oMask,[]);
colormap(mycmap);
colorbar;
我使用Matlab中的UI制作了自定义图例。
我不知道如何获取代码,它显示为64x3双精度
数组如下所示(对不起,我不知道如何在这里制作表)

我使用的函数是在GitHub上找到的。 链接如下:


您的代码使用了未包含的自定义颜色贴图和功能(热图覆盖),因此很难为您提供帮助。使用默认的颜色贴图,密度图像看起来很好,所以我怀疑您的自定义颜色贴图或函数中有什么东西。此外,此示例不需要代码的文件导入部分。抱歉,感谢提醒。我现在已经上传了自定义颜色贴图。我不知道它是作为数组编写的。我还链接到了所使用的函数。我注意到“colorfun='jet';”和jet的状态,并且是一个颜色映射选项。这可能是问题所在吗?我注意到函数heatmap_overlay()只能调用三种颜色样式,而且是可选的。如何从函数中省略颜色,并让Matlab识别我在图例中设置的颜色?
0.00196078442968428 0.00196078442968428 1
0.107223942875862   0.00196078442968428 1
0.212487101554871   0.00196078442968428 1
0.317750245332718   0.00196078442968428 1
0.423013418912888   0.00196078442968428 1
0.528276562690735   0.00196078442968428 1
0.633539736270905   0.00196078442968428 1
0.738802909851074   0.00196078442968428 1
0.844066023826599   0.00196078442968428 1
0.949329197406769   0.00196078442968428 1
1   0.00196078442968428 0.949329197406769
1   0.00196078442968428 0.844066023826599
1   0.00196078442968428 0.738802909851074
1   0.00196078442968428 0.633539736270905
1   0.00196078442968428 0.528276562690735
1   0.00196078442968428 0.423013418912888
1   0.00196078442968428 0.317750245332718
1   0.00196078442968428 0.212487101554871
1   0.00196078442968428 0.107223942875862
1   0.00196078442968428 0.00196078442968428
1   0.0575163401663303  0.00196078442968428
1   0.113071896135807   0.00196078442968428
1   0.168627455830574   0.00196078442968428
1   0.224183008074760   0.00196078442968428
1   0.279738575220108   0.00196078442968428
1   0.335294127464294   0.00196078442968428
1   0.390849679708481   0.00196078442968428
1   0.446405231952667   0.00196078442968428
1   0.501960813999176   0.00196078442968428
1   0.557516336441040   0.00196078442968428
1   0.613071918487549   0.00196078442968428
1   0.668627440929413   0.00196078442968428
1   0.724183022975922   0.00196078442968428
1   0.779738545417786   0.00196078442968428
1   0.835294127464294   0.00196078442968428
1   0.890849649906158   0.00196078442968428
1   0.946405231952667   0.00196078442968428
1   1   0.00196078442968428
0.911051690578461   1   0.00196078442968428
0.820142626762390   1   0.00196078442968428
0.729233503341675   1   0.00196078442968428
0.638324439525604   1   0.00196078442968428
0.547415316104889   1   0.00196078442968428
0.456506252288818   1   0.00196078442968428
0.365597158670425   1   0.00196078442968428
0.274688065052032   1   0.00196078442968428
0.183778971433640   1   0.00196078442968428
0.0928698778152466  1   0.00196078442968428
0.00196078442968428 1   0.00196078442968428
0.00196078442968428 0.968496739864349   0.00196078442968428
0.00196078442968428 0.935032665729523   0.00196078442968428
0.00196078442968428 0.901568651199341   0.00196078442968428
0.00196078442968428 0.868104577064514   0.00196078442968428
0.00196078442968428 0.834640502929688   0.00196078442968428
0.00196078442968428 0.801176488399506   0.00196078442968428
0.00196078442968428 0.767712414264679   0.00196078442968428
0.00196078442968428 0.734248340129852   0.00196078442968428
0.00196078442968428 0.700784325599670   0.00196078442968428
0.00196078442968428 0.667320251464844   0.00196078442968428
0.00196078442968428 0.633856236934662   0.00196078442968428
0.00196078442968428 0.600392162799835   0.00196078442968428
0.00196078442968428 0.566928088665009   0.00196078442968428
0.00196078442968428 0.533464074134827   0.00196078442968428
0.00196078442968428 0.500000000000000   0.00196078442968428