- As per my understanding to create a mask of the pure white section in the blurred image, a thresholding technique can be used. Since the pure white section corresponds to the least blurred region, it will have higher pixel values compared to the rest of the image.
- The "imbinarize" function can be used to convert the grayscale image "I_lap_norm" into a binary image based on the specified threshold value.
- Pixels with values above the threshold are set to 1 (white), and pixels below the threshold are set to 0 (black). The resulting binary image "mask" represents the pure white section of the blurred image.
How to make a mask of a noiseless section of an image
2 ビュー (過去 30 日間)
古いコメントを表示
Hi. I'm trying to detect and eliminate a blurred section of an image.
Right now I have found a way to detect a blurred section with Laplacian with the code below and reversed the colors with the last line (just for visualizing purposes), as seen on the image.
I realized that is the only section that is noiseless, since the rest of the image have a lot of noise. Is there a way to use that to just create a mask of the pure white (or black if is simpler) section? I was thinking of making an if section that checks for black pixels arround. It's not a problem if it masks a little extra on the edges.
Thanks for you help in advance.
clear all;
close all;
clc;
I = imread('a2.png');
H = zeros(size(I,1),size(I,2));
I_fft = fftshift(fft2(I));
for i = 1:size(I,1)
for j = 1:size(I,2)
H(i,j) = -((i-size(I,1)/2)^2+(j-size(I,2)/2)^2);
end
end
I_lap = real(ifft2(ifftshift(I_fft.*H)));
I_lap_norm = I_lap/max(max(I_lap));
figure()
imshow(I_lap_norm)
imshow(imdilate(I_lap_norm,offsetstrel('ball',1,1)));
0 件のコメント
回答 (1 件)
Maneet Kaur Bagga
2023 年 9 月 27 日
Hi Fernando,
% Threshold value to separate the pure white section
threshold = 0.9;
% Create a binary mask based on the threshold
mask = imbinarize(I_lap_norm, threshold);
% Display the mask
figure()
imshow(mask)
Please refer to the MATLAB documentation for further information on the "imbinarize" function:
Hope this helps!
Regards,
Maneet Bagga
0 件のコメント
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!