0

I have a specific question to ask about the intensity adjustment for image processing. I need high constraint value to find small gaps in the image which is shown as a red circle in the image. I used a manual threshold value 0.99 to convert the grayscale image to binary image for other processing methods. However, as the illumination on the surface did not distribute evenly, some parts of the image is lost. I used the adaptive method suggested by Matlab, however, the results is similar to a global threshold graythresh.

I will show my code and result below.

Red point as interesting area

Original file

I0 = imread('1_2.jpg');
[R,C,K] = size(I0);
if K==1
    I1 = I0;
else
    I1 = rgb2gray(I0);
end

%Adjsut image to get a standar binary picture
%Adjust image intensity value
I1 = imadjust(I1,[0.1 0.7],[]);
BW0   = im2bw(I1,0.99);
    figure;
BW0   = bwareaopen(BW0,10000);
%Fill non_crack hole error
BW0   = bwareaopen(1-BW0,500);
BW0   = 1-BW0;
    imshow(BW0);

After this process, only half of the image will be left. I want a whole image, with locally intensity threshold but show the same feature as the high-level threshold. What can I do?

Thanks

Chen
  • 13
  • 5
  • 1
    @Nemus Your edit should not introduce grammatical errors. Every word change you suggested is wrong. – beaker Apr 29 '17 at 18:23
  • Thank you! This makes it clear, What I want to achieve is remaining the small gap feature at the red point as well as show the image as a whole. – Chen Apr 29 '17 at 18:43

1 Answers1

0

Try adaptthresh:

I0 = imread('1_2.jpg');
[R,C,K] = size(I0);
if K==1
    I1 = I0;
else
    I1 = rgb2gray(I0);
end

T = adaptthresh(I1, 0.4);    %adaptive thresholding
% Convert image to binary image, specifying the threshold value.

BW = imbinarize(I1,T);
% Display the original image with the binary version, side-by-side.

figure
imshowpair(I1, BW, 'montage')
qbzenker
  • 4,412
  • 3
  • 16
  • 23
  • Thanks for the comment, I used that one, but the small gap I want to remain at the red point is gone as well. – Chen Apr 29 '17 at 18:41