background removal from image
조회 수: 36 (최근 30일)
Hi , I am working on a project in color illusion. And I want to remove the background from the image, the image is a person's face with white bakground, I used matlab function color thresholding to remove the background, after that I convertd the image color space to DKL space, then I started with my project, but still in my analysis the whole image is getting calculated . I want to work with the histogram of the person's face not the background. I am attaching my whole code here.. kindly help me.
2. since I am new to matlab, I learnt my codes in bits and pieces using tutorial, I want to know how to connect all my pieces together. Like starting from background removal, then using the background removed image to convert in different color space. finally using this color space image in calculating my histograms and creating illusion. so, I have written my codes in parts ... that does all this function but not together in one script. I am stuck with how to combine all these.
Kindl guide me through this
Subhadeep Koley 2020년 5월 27일
Malini, here is a demo script for "...histogram of the person's face not the background..."
img = imread('dkloriginalimg.jpg');
% Create a binary image mask
grayImg = rgb2gray(img);
maskBW = grayImg(:, :) ~= 0;
maskBw = imfill(maskBW, 'holes');
% Display original image
subplot(1, 3, 1)
% Display the mask
subplot(1, 3, 2)
% Calculate the histogram
pixelsWithinMask = img(maskBw);
[pixCnt, lavels] = imhist(pixelsWithinMask);
subplot(1, 3, 3)
title('Histogram of the masked image')
Hope this helps!