Hi,
With a laser I ablated a certain area from an ink sample. Not the entire layer is ablated. Therefore, the contrast of the hole with the surrounding area is low.
With image processing I would like to determine the area of the ablated hole. This information would be very valuable for my research.
Below you find the script with my attempts to solve this problem. please help.
Kind regards,
Hidde
clear all; close all; clc;
I = imread('400_2_300.jpg');
I = rgb2gray(I);
imh = imadjust(I);
J = medfilt2(imh);
se = strel('disk',25);
thfilter = imtophat(J,se);
adjust = imadjust(thfilter);
bin = im2bw(adjust,0.35);
fill = imfill(bin,'holes')
filt_bin = medfilt2(bin);
fill1 = imfill(filt_bin,'holes');
img_close = imclose(fill1 , strel('disk', 1));
%take complement to adhere to convention
imgbw = imcomplement(fill1) ;
%make bridges across small "leaks"
img_close = imclose(imgbw , strel('disk',5));
%find holes in resulting image
holes = ~img_close & imfill(img_close, 'holes');
%add back holes to original image
img_filled = imfill((imgbw | holes) , 'holes');
%optional additional filling
img_filled_closed = imclose(img_filled, strel('disk', 5)) ;
figure(1), clf(1), hold on
subplot(3,3,1)
imshow(I)
subplot(3,3,2)
imshow(imh)
subplot(3,3,3)
imshow(J)
subplot(3,3,4)
imshow(thfilter)
subplot(3,3,5)
imshow(adjust)
subplot(3,3,6)
imshow(bin)
subplot(3,3,7)
imshow(fill)
subplot(3,3,8)
imshow(fill1)
subplot(3,3,9)
imshow(img_filled_closed)
hold off