Matlab 如何创建图像覆盖?更改边颜色

Matlab 如何创建图像覆盖?更改边颜色,matlab,cat,sobel,Matlab,Cat,Sobel,如何创建图像覆盖?更改边缘颜色: 为了将边缘更改为绿色,首先我使用了“sobel”,但是覆盖部分有一个错误:IMG必须是灰度或RGB图像的数组:writeVideowriter,doubleout;为什么? out_red(BW)=0; out_green(BW)=255; out_blue(BW)=0; writeVideo(writer,double(uint8(out))); close(writer); 请尝试以下操作: redChannel =

如何创建图像覆盖?更改边缘颜色: 为了将边缘更改为绿色,首先我使用了“sobel”,但是覆盖部分有一个错误:IMG必须是灰度或RGB图像的数组:writeVideowriter,doubleout;为什么?

    out_red(BW)=0;
    out_green(BW)=255;
    out_blue(BW)=0;


    writeVideo(writer,double(uint8(out)));


close(writer);
请尝试以下操作:

redChannel = inputImage(:, :, 1);
greenChannel = inputImage(:, :, 2);
blueChannel = inputImage(:, :, 3);
writeVideo(writer, uint8(out));
如果writeVideo类的范围为{0,1,2,…,255},则该类期望数据为uint8。
如果要使用单数据或双数据,则需要将其缩放回[0,1]范围。

您错误地将整个img设置为每个颜色通道,它应该是这样的:

out_red=img(:,:,1);
out_green=img(:,:,2);
out_blue=img(:,:,3);

最后写一个deoWriter,uint8out

这样做有一个错误:IMG必须是灰度或RGB图像的数组,然后我尝试了这个:writeVideowriter,doubleuint8out;但仍然有错误:IMG必须是灰度或RGB图像的数组。为什么?你没有单独提取每个通道。请参阅我的编辑。