我应该在阈值图像旁边添加另一幅图像,其原始颜色如下:expected image
但是我不确定在Matlab上仅达到二进制图像阈值时该怎么做。如何并排显示图像?
clear all;
close all;
clc;
% read image
palm = imread('palmDown (2).jpg');
%split into RGB
redPalm = palm(:,:,1);
greenPalm = palm(:,:,2);
bluePalm = palm(:,:,3);
redLevel = -0.1;
greenLevel = -0.1;
blueLevel = 0.06;
redThresh = imbinarize(redPalm, redLevel);
greenThresh = imbinarize(greenPalm, greenLevel);
blueThresh = imbinarize(bluePalm, blueLevel);
colorSum = (redThresh&greenThresh&blueThresh);
colorSum2 = imcomplement(colorSum);
thumbFilled = imfill(colorSum2, 'holes');
figure;
imshow(thumbFilled); title('Sum of all');
答案 0 :(得分:0)
有许多方法可以使阈值图像着色。一种简单的方法是通过乘法:
palm = im2double(palm); % it’s easier to work with doubles in MATLAB
palm2 = palm * thumbFilled;
imshow([palm, palm2])
乘法使用隐式Singleton扩展。如果您使用的是较旧版本的MATLAB,则无法使用,则必须改用bsxfun
。