为什么我得到这个教程的错误时,适应我的图像?我如何修复这个错误:

3次浏览(过去30天)
clc; 清除命令窗口。
清晰; 删除所有变量。
关闭 所有 关闭所有图形窗口,imtool创建的图形窗口除外。
关闭所有;关闭imtool创建的所有图形窗口。
工作空间; 确保显示工作区面板。
Lab_fabric = rgb2lab( “image.tif” );
A = lab_fabric(:,:,2);
B = lab_fabric(:,:,3);
color_markers =零([nColors, 2]);
count = 1:nColors
Color_markers (count,1) = mean2(a(sample_regions(:,:,count)));
Color_markers (count,2) = mean2(b(sample_regions(:,:,count)));
结束
color_labels = 0:nColors-1;
A = double(A);
B = double(B);
距离= 0 ([size(a), nColors]);
count = 1:nColors
距离(:,:,数)= ((a - color_markers(计数,1))。^ 2 + ...
(b - color_markers(count,2))。^ 2)。^ 0.5;
结束
[~,label] = min(距离,[],3);
Label = color_labels(Label);
清晰的 距离
Rgb_label = repmat(label,[1 1 3]);
segmented_images = 0 ([size(fabric), nColors], “uint8” );
count = 1:nColors
颜色=面料;
Color (rgb_label ~= color_labels(count)) = 0
Segmented_images (:,:,:,count) = color;
结束
蒙太奇({segmented_images (:,:,: 2), segmented_images (:,:,: 3) ...
segmented_images (::: 4), segmented_images (:,:,: 5) ...
segmented_images (::,:, 6), segmented_images (:,:,: 1)});
标题( 红色,绿色,紫色,品红和黄色物体的蒙太奇,和背景
错误:
使用rgb2lab出错
期望输入数字1 RGB是以下类型之一:
单,双,uint8, uint16
rgb2lab错误(第56行)
validateattributes (rgb,…
测试中的错误(第7行)
Lab_fabric = rgb2lab('image.tif');

接受的答案

卡里姆
卡里姆 2022年12月26日
然后你忘记了 进口 图像,从 imread 函数读取图像,然后调用rgb2lab
织物= imread(“fabric.png”);
Lab_fabric = rgb2lab(fabric);
1评论
沃尔特·罗伯森
沃尔特·罗伯森 2022年12月26日
很少有图像相关的函数接受文件名。Imread()执行if course, imshow()也执行。我似乎记得其中一个图像蒙太奇功能接受文件名。还有一些图像信息功能。但是对于imread以外的任何东西,您应该始终检查文档,以确保它接受文件名。更安全的假设是,大多数函数要求您传递图像数据而不是文件名。

登录评论。

更多答案(0)

世界杯预选赛小组名单社区寻宝

在MATLAB Central中找到宝藏,并发现社区如何帮助您!世界杯预选赛小组名单

开始狩猎!

Baidu
map