
How do I remove the background (specifically the vignette) from this image without removing the particles of sand?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Samuel Nathan Bernas
le 24 Juil 2023
Commenté : Samuel Nathan Bernas
le 25 Juil 2023
I am doing research where my goal is to remove out of focus particles of sand, and count in focus particles of sand that I capture in lab. I am currently trying to isolate the objects using imgradient but the vignette hinders the ability to distinguish a gradient. I would like to remove the backround vignette as it disrupts the ability to count the particles. I would appreciate any help!
Here's my code (readPGRaw is code we wrote in order to read in our raw images):
filename= '/Users/sammybuckets/Documents/SandTests/S5_2023-07-18-193451-0000.raw';
ubit= 8;
size= [2448 2048 1];
I = readPGRaw(filename,ubit,size);
figure
G= imgradient(I);
J= G>110;
imagesc(J)
axis image
colormap gray
[JV, JU]= find(J);
hold on
plot(JU,JV,'.')
se = strel('disk',15);
closeJ = imclose(J,se);
[JVC, JUC]= find(closeJ);
plot(JUC,JVC,'.')
plot(JU,JV,'.')
BW2 = imfill(closeJ,'holes');
figure
imshow(BW2)
title('Filled Image')
0 commentaires
Réponse acceptée
Image Analyst
le 25 Juil 2023
Your best bet is to take a separate, blank shot with no particles in the field of view and then divide your particle images by that blank image. Then you can just use a simple fixed global threshold. Attached is a demo.

Plus de réponses (1)
Angelo Yeo
le 25 Juil 2023
I = imread('raw.png');
%% Removing Vignette and binarizing image
sigma = 20;
Iflatfield = imflatfield(I, sigma);
Iflatfield = rgb2gray(Iflatfield);
BW = imbinarize(Iflatfield);
IBW = uint8(zeros(size(BW)));
IBW(~BW) = 255;
%% applying morphologies
J = medfilt2(medfilt2(IBW));
SE = strel('ball',5, 5);
J = imerode(J, SE);
SE = strel('ball', 4, 4);
J = imdilate(J, SE);
%% check results
C = imfuse(I, J,"falsecolor");
imshow(C)
0 commentaires
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
