How to do OR operation of two images (DFT and Binary)?

38 次查看(过去 30 天)
This is the image where i want to identify the cracks and find the area or percentage of cracks. First i converted the into binary and then i found the dft image of this image. afterthat i want to apply bit-by-bit OR method to make the cracks more clear and afterthat i want to find the area or %age of crack. The .m file is attached.
Thanks in advance.
  2 个评论
Walter Roberson
Walter Roberson 2021-6-12
It would be more efficient if you were to replace
for x=1:m
for y=1:n
r=f(x,y);
if(r>=t)
g(x,y)=1;
else
g(x,y)=0;
end
end
end
with the single line:
g = f >= t;
No loops are needed for that part.

请先登录,再进行评论。

回答(3 个)

Image Analyst
Image Analyst 2021-6-12
To me this looks like a series of 3 tiles butted together. And you want to find the thin crack that's vertical in the middle tile. You do not want to find the thick black lines separating the tiles since these are not cracks that you are interested in. Nor do you want to find the thick black zone around the edge of the image so you first need to mask those out.
The best way would be to put your tiles into some kind of positioning jig in your light booth where the tiles are in the same position all the time. Then you can simply make a mask and white those areas so they don't appear as cracks.
grayImage(mask) = max(grayImage(:));
Next you need to find the cracks. They will be dark and thin. So first you need to threshold and then find long thin blobs. Try the 'adaptive' option of imbinarize() or else try a ridge finding filter like Frangi, COSFIRE-B, or a Hessian.
Now that you have a good image and have thresholded it properly you can further examine the blobs that are left for the proper aspect ratio. It would take long experimentation (hours which I can't afford to donate to you) but you might try these functions bwpropfilt(), bwferet(), bwdist(), regionprops(), bwskel(). The distance transform will tell you the distance from each pixel in the blob to the nearest edge of the blob, and if you multiply it by the skeleton gotten from bwskel(), you get the width of the blob everywhere. See attach demo.
  1 个评论
Miraj Khalid
Miraj Khalid 2021-6-12
Hello Sir, Sir this is the image of solar cell which have some micro-cracks.
Exactly the vertiical dark lines are not cracks.
actually I'm trying to implement the following paper which includes three steps:
1:Geometric properties of the obtained binary image (Binarization).
2:Discrete Fourier Transform (DFT) image processing.
3:Bit-by-bit OR method.
https://www.sciencedirect.com/science/article/pii/S2468217919302345

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2021-6-12
m=imshow(uint8(abs(Output)/60))
should be replaced with
m = uint8(abs(Output)/60);
imshow(m)
and
OR1=bitor(g, m);
should be replaced with
OR1 = bitor(uint8(g), m);

DGM
DGM 2021-6-12
I'm not sure what you're actually trying to do. Your description makes sense, but you're doing the bitwise OR of a logical image and a graphics object handle. Even if you were to operate on the image in the figure, it's not the right size.
figure(2);
% get rescaled magnitude image, resize
% using uint8() like this is going to truncate a lot
% i have no idea what the magic number 60 is for
p = imresize(uint8(abs(Output)/60),size(g),'bilinear');
subplot(1,2,1), imshow(p)
% using bitor() with logical array g only changes the LSB of p
% bitor() doesn't neatly handle logical inputs if other input is integer
OR1=bitor(uint8(g),p);
% are you trying to do logical masking or something?
% if so, p is almost 100% nonzero, it will simply be treated as logical 1
%p = p>0.2; % maybe apply a threshold or something?
%OR1 = g | p; % just do logical OR?
% even at that, the logical OR of two mostly-white images is unlikely
% to be anything visually useful
subplot(1,2,2), imshow(OR1);
The images look identical because only the LSB is being changed.
  3 个评论
DGM
DGM 2021-6-12
编辑:DGM 2021-6-12
I know you have g and m (i used p instead of m, but that doesn't matter).
I know the images are the mismatched size. That's why I mentioned it and showed how to resize them to match.
I don't understand how doing either logical or bitwise OR will make anything clearer. If this is some frequency domain processing technique, I doubt it's done like this.
For reference, these are g and p (you can call it m if you want)
This is the bitwise OR of the two. The difference is only in the LSB, so it's not practically visible:
This is the logical OR of the two. Like I said, p is almost 100% nonzero. You'd be taking the OR of two images that are almost entirely white. This is what you'd get:
If you threshold or offset p, you might get a different result. Let's say p = p>128;
You can see the remnants of p in there, but this doesn't visually mean anything, and it certainly doesn't emphasize the cracks.
Image Analyst
Image Analyst 2021-6-12
Right - multiplying a spectral domain image by an image gotten from the spatial domain makes absolutely no sense whatsoever. Just think about it. It's nonsense, totally.

请先登录,再进行评论。

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by