0

I'm supposed to add another image next to my threshold image with its original color like so: expected image

But I'm unsure how to do it having only achieving the binary image threshold on matlab. How do I show images side by side?

my result

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');
Jason Tan
  • 1
  • 2

1 Answers1

0

There are many ways to colorize the thresholded image. One simple way is by multiplication:

palm = im2double(palm); % it’s easier to work with doubles in MATLAB
palm2 = palm * thumbFilled;
imshow([palm, palm2])

The multiplication uses implicit Singleton expansion. If you have an older version of MATLAB it won’t work, you’ll have to use bsxfun instead.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120