Binarizing image with single pixels

4 次查看(过去 30 天)
Mat
Mat 2024-1-29
回答: Animesh 2024-1-30
I have some photos of random pixels marked on a low noisy background. I want to binarize the image, in order to have a clear array of 0s and 1s, and I would like to make each spot as one element of the matrix.
What I did was to grayscale the image, and then try to binarize it. Unfortunately, it is not enough. Adding Adaptive histeresys equalisation (Ae = adapthisteq(Ag);) makes it worst. Maybe strel function could help?
Thanks
This is my code. I think code will be similar to datamatrix and QR code reading.
Thank you
if dim ~= 1
Ag = rgb2gray(photo);
else
Ag = photo;
end
Ab=imbinarize(Ag);

回答(1 个)

Animesh
Animesh 2024-1-30
Hi @Mat
If you're working with an image that has random pixels against a faintly noisy background and wish to detect those random pixels, you can employ morphological operations to enhance the features of the spots and distinguish them from the background noise.
A suggested approach you can try is:
Step 1: Convert the image to greyscale (if not already).
Step 2: Apply a filter to reduce noise.
Step 3: Binarize the image using thresholding.
Step 4: Use morphological operations to clean up the image and isolate the spots.
You can refer to the following documentation on morphological operations:

类别

Help CenterFile Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by