How do i binarize these two images to produce an as equal result as possible?

1 view (last 30 days)
The two attached images of a porous material are aquired at the same area but as with all aquired images there is a slight difference.
When i binarize the images and compare the area of each pore between the two images, the mean difference in measured area is about 5 %, due to that it does not define the pore edges at the exact same place.
How do i binarize these two images to make them as equal as possible after binarization? This could ofcourse include pre-processing as well.
Any suggestions would be greatly appreciated!

Answers (1)

Rohit Pappu
Rohit Pappu on 25 Jan 2021
Since Image 2 is a horizontally shifted version of Image 1, a possible workaround could be as follows
% Load the images to workspace
I1 = imread('1.png');
I2 = imread('2.png');
% Convert images to grayscale
I1bw = rgb2gray(I1)
I2bw = rgb2gray(I2)
% Pick a reference point in the first image
pixel = I1bw(1,1);
% Find the first occurence of similar pixel in first row of second image
pixelshift = find(pixel == I2bw(1,:),1,"first")
% Shift the second image left by 'pixelshift' amount of pixels
I2shift = imtranslate(I2bw,[-pixelshift,0],"linear")
% Crop the pixelshift number of colums on the right of both images
% to get rid of the interpolated values
I1bw = I1bw(:,1:end-pixelshift);
I2shift = I2shift(:,1:end-pixelshift);
% View both the images simultaneously with false color overlay

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!