MATLAB: How to count number of matching pixels in two regions. Actually I want to calculate number of pixels in green region (which is indicating detected region).similarly I need to count number of pixel in white region of attached image.

copy move forgeryimage forensicImage Processing Toolboximage segmentation

Best Answer

Number of matching pixels in red and green region for your image can be calculated by:
% Read the image
I = imread('015_F_countPix.png');
% Extract the maximum red area and count the number of pixels
BW1 = I(:,:,1) == 255;
BW1 = bwareafilt(BW1,1);
pixNumRed = nnz(BW1 == 1);
% Same for the green area
BW2 = I(:,:,2) == 255;
BW2 = bwareafilt(BW2,1);
pixNumGreen = nnz(BW2 == 1);