image - 显示 matlab 的图形窗口

标签 image matlab

我编写了这段代码来帮助我比较不同的图像直方图,但是当我运行它时,我会弹出一个图形窗口。我在代码中看不到我编写的 imshow 的任何地方,我真的很困惑。谁能明白为什么吗?谢谢

%ensure we start with an empty workspace
clear

myPath= 'C:\coursework\'; %#'
number_of_desired_results = 5; %top n results to return

images_path = strcat(myPath, 'fruitnveg');
images_file_names = dir(fullfile(images_path, '*.png'));
images = cell(length(images_file_names), 3);
number_of_images = length(images);

%textures contruction
%loop through all textures and store them
disp('Starting construction of search domain...');
for i = 1:length(images)
    image = strcat(images_path, '\', images_file_names(i).name); %#'

    %store image object of image
    images{i, 1} = imread(image);
    %store histogram of image
    images{i, 2} = imhist(rgb2ind(images{i, 1}, colormap(colorcube(256))));
    %store name of image
    images{i, 3} = images_file_names(i).name;
    disp(strcat({'Loaded image '}, num2str(i)));
end
disp('Construction of search domain done');

%load the three example images

RGB1 = imread('C:\coursework\examples\salmon.jpg');
X1 = rgb2ind(RGB1,colormap(colorcube(256)));
example1 = imhist(X1);

RGB2 = imread('C:\coursework\examples\eggs.jpg');
X2 = rgb2ind(RGB2,colormap(colorcube(256)));
example2 = imhist(X2);

RGB3 = imread('C:\coursework\examples\steak.jpg');
X3 = rgb2ind(RGB3,colormap(colorcube(256)));
example3 = imhist(X3);

disp('three examples loaded');

disp('compare examples to loaded fruit images');

results = cell(length(images), 2);

results2 = cell(length(images), 2);

results3 = cell(length(images), 2);

for i = 1:length(images)
    results{i,1} = images{i,3};
    results{i,2} = hi(example1,images{i, 2});
end

results = flipdim(sortrows(results,2),1);

for i = 1:length(images)
    results2{i,1} = images{i,3};
    results2{i,2} = hi(example2,images{i, 2});
end

results2 = flipdim(sortrows(results2,2),1);

for i = 1:length(images)
    results3{i,1} = images{i,3};
    results3{i,2} = hi(example3,images{i, 2});
end

results3 = flipdim(sortrows(results3,2),1);

最佳答案

如果没有创建图窗,则colormap函数设置当前图窗的颜色图。

imhist 的第二个参数应该是直方图中使用的 bin 数量,而不是颜色图。

关于image - 显示 matlab 的图形窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22690413/

相关文章:

matlab - 如何在matlab中寻址立方体(3d数组)的所有面?

python - 可在当前命名空间中转储的可挑选数据容器

matlab - 在 Matlab 中捕获实时命令窗口输出

Matlab:高斯消去函数

arrays - 如何通过设置的按钮单击次数显示然后更改图像数组

path - MATLAB:将当前文件夹设置为脚本位置

java - 使用具有大数据的 ZXing 库生成条码时遇到问题

c++ - 使用 OpenCV 将图像旋转 90 度的最简单方法?

javascript - 如何将图像宽度设置为 clientHeight x 5.128571428571429

css - 多文件夹组织和引用 CSS