how do I filter noise and background objects from images?

23 visualizaciones (últimos 30 días)
i have images that have these cylindrical objects that i want removed before doing analysis? How do I remove them?
Thank you

Respuesta aceptada

Image Analyst
Image Analyst el 14 de En. de 2023
Do what? Erase/blacken those black regions from the original image? You simply do
grayImage(~mask) = 0;
If you don't have the mask yet then you need to segment your image to get objects. Then try to find some property that distinguishes "cylindrical/sinusoidal objects" (whatever those are or look like) from other objects. We can't really help (yet) since you forgot to attach the original image. You only attached the segmented image (mask).
  34 comentarios
Image Analyst
Image Analyst el 23 de En. de 2023
I don't know what the "max noise" is.
Matthew Worker
Matthew Worker el 23 de En. de 2023
Is there a way that I can determine that?

Iniciar sesión para comentar.

Más respuestas (2)

Matt J
Matt J el 14 de En. de 2023
Editada: Matt J el 14 de En. de 2023
Perhaps with bwpropfilt(____,'Eccentricity', range)
  4 comentarios
Matt J
Matt J el 15 de En. de 2023
Editada: Matt J el 15 de En. de 2023
but I am unsure how to format the code such that it extracts those objects that I circled.
I am wondering why the blob circled in red was excluded. It has a similar shape to those circled in white.
Matthew Worker
Matthew Worker el 15 de En. de 2023
in other images I have these are just areas of non interest. and the areas in black have pixels of interest that's why i want them removed.
I just circled 3 for example but all of the long cylindrical objects will be removed. heres another example where here all the black parts of the image will be removed leaving the green pixelated areas for analysis.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 15 de En. de 2023
If you want a script to extract only the round blobs, try this:
% Demo by Image Analyst
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
%===============================================================================
% Get the name of the image the user wants to use.
baseFileName = 'D45F33C9-CCA7-4815-B426-07D56A8657D7.jpeg';
folder = pwd;
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
%=======================================================================================
% Read in image.
rgbImage = imread(fullFileName);
% Get the dimensions of the image.
[rows, columns, numberOfColorChannels] = size(rgbImage)
% Display image.
subplot(2, 2, 1);
imshow(rgbImage, []);
impixelinfo;
axis on;
caption = sprintf('Original RGB Image\n%s', baseFileName);
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Set up figure properties:
% Enlarge figure to full screen.
g = gcf;
g.WindowState = "maximized";
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
drawnow;
%--------------------------------------------------------------------------------------------------
% Create a logical image mask.
mask = rgbImage(:, :, 2) > 128;
% Get areas
props = regionprops(mask, 'Area')
allAreas = sort([props.Area])
% Display image.
subplot(2, 2, 2);
imshow(mask, []);
impixelinfo;
axis on;
caption = sprintf('Initial Mask with %d blobs', numel(allAreas));
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Get rid of blobs less than 100 pixels in area
mask = bwareaopen(mask, 100)
% Get rid of partial blobs (those touching the border).
mask = imclearborder(mask);
% Get areas
props = regionprops(mask, 'Area', 'Circularity')
allAreas = sort([props.Area])
allCircs = [props.Circularity]
% Display image.
subplot(2, 2, 3);
imshow(mask, []);
impixelinfo;
axis on;
caption = sprintf('Next Mask with %d blobs', numel(allAreas));
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
% Filter out non-circular blobs.
[labeledImage, numBlobs] = bwlabel(mask);
roundBlobsOnly = ismember(labeledImage, find(allCircs > 0.6));
% Display image.
subplot(2, 2, 4);
imshow(roundBlobsOnly, []);
impixelinfo;
axis on;
caption = sprintf('Final Mask with %d round-only blobs', sum(allCircs > 0.6));
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo(); % Set up status line to see values when you mouse over the image.
  16 comentarios
Image Analyst
Image Analyst el 25 de En. de 2023
Note, the area fraction = (# foreground pixels) / (total # of pixels in ROI) is not the same as the count density = (# distinct blobs) / (total # of pixels in ROI). You can get either and/or both - just depends on what will help you in your further analysis.
Matt J
Matt J el 25 de En. de 2023
where would the BW function come into effecct earlier in the code?
@Chanille BW is your image, assumed here to be binary. Binarization of your image is a necessary step in any approach you take here, since the objects of interest need to be identified in some way.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by