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

1 view (last 30 days)
Holmbrero on 22 Jan 2021
Commented: Holmbrero on 25 Jan 2021
Hi!
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!

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
% 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
imshowpair(I1bw,I2shift)
Holmbrero on 25 Jan 2021
I will give it a go and get back with the result.

### Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

R2018b

### Community Treasure Hunt

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

Start Hunting!

Translated by