Removing ghost rings on CCD reading?

38 visualizaciones (últimos 30 días)
Timothy
Timothy el 8 de En. de 2026 a las 2:58
Respondida: Mathieu NOE hace alrededor de 18 horas
Hello! I have a matrix were each value contains a level of intensity. I do some data manipulation on my data, and create these plots. My function that removes the ghost rings is horrible because it pouches everything. My goal is to only pouch the shadow ring. Can I get some advice on how to deal with it? TThanks!
  5 comentarios
Mathieu NOE
Mathieu NOE hace 5 minutos
if I look at the second image this seems quite a nice result - what is the "other stuff" that we shall not impact ?
Timothy
Timothy hace 6 minutos
The fuzzy looking stuff should stay. The ONLY issue is the fait shifted curve inside of that fuzzy area.

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst hace alrededor de 8 horas
To me, in the US, poach is something you do to cook an egg, or to hunt animals illegally. I assume you mean "remove" or "filter out". How many do you have to do? Could you just manually paint them out. If you have hundred of them, you might make a script. If the inside of the ring is supposed to be black, I would first threshold the image at a high enough level to only get the major ring. Then use imdilate to widen the ring a desired amount. Then use the mask to erase everything outside of the ring. Something like (untested)
mask = grayImage > someGrayLevel; % You specify this, or try using imbinarize().
se = strel('disk', 7); % Change 7 to whatever width you want.
mask = imdilate(mask, se); % Widen the mask.
% Erase gray image outside the mask
outputImage = grayImage; % Initialize
outputImage(~mask) = 0; % Erase.
imshow(outputImage, []);
If you have any more questions, then attach your image with the paperclip icon after you read this:

Mathieu NOE
Mathieu NOE hace alrededor de 4 horas
made a quick and dirty code just to see how far I could go without the Image procesing Tbx
well, you may find that usefull or not maybe with some extra work you can further improve it to the performance level you want .
the code requires you to download this fex submission : inpaint_nans - File Exchange - MATLAB Central
% Read the input image
A = imread('image0.png');
A = rgb2gray(A); % Convert to grayscale if it's a color image
A = double(A);
A = flipud(A); % to have image displayed with correct y direction
[yy,xx] = size(A);
[y,x] = find(A>60); % threshold (identify main ring)
figure(1)
imagesc(A);
colorbar('vert');
set(gca,'YDir','normal');
colormap('gray');
hold on
axis square
plot(x,y,'.')
% center of main ring
xc = mean(x);
yc = mean(y);
[theta,r] = cart2pol(x-xc,y-yc);
%% find the inner boundary of the main ring
% "interpolated/mean" of r,z values : take the average of r and z within an angle domain
Npoints = 180;
theta_new = linspace(min(theta),max(theta),Npoints);
dt = mean(diff(theta_new));
for k = 1:Npoints
ind = (theta>=theta_new(k)-dt/2) & (theta<theta_new(k)+dt/2);
if isempty(ind)
r_new(k) = NaN;
else
r_new(k) = min(r(ind));
end
end
% remove outliers inside main ring (bright spots)
ind = r_new./mean(r_new)<0.8;
r_new(ind) = [];
theta_new(ind) = [];
% convert to cartesian
[xn,yn] = pol2cart(theta_new,r_new);
% add back centroid info
xn = xn + xc;
yn = yn + yc;
% closing the curve
xn(end+1) = xn(1);
yn(end+1) = yn(1);
plot(xn,yn,'g.')
%% select pixels inside main ring (using inpolygon)
[X,Y] = meshgrid((1:xx),(1:yy));
in = inpolygon(X(:),Y(:),xn,yn);
logical_mask = reshape(in,size(A));
figure(2)
B = A.*logical_mask;
imagesc(B);
colorbar('vert');
set(gca,'YDir','normal');
colormap('gray');
clim([0 100])
axis square
figure(3)
B(B>27) = NaN; % remove major ghost circle (quite sensitive to threshold)
% now fill / interpolate NaN values
Bf = inpaint_nans(B,0);
imagesc(B);
colorbar('vert');
set(gca,'YDir','normal');
colormap('gray');
axis square
clim([0 100])
AA = A.*(~logical_mask) + Bf;
figure(4)
imagesc(AA);
colorbar('vert');
set(gca,'YDir','normal');
colormap('gray');
axis square

Community Treasure Hunt

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

Start Hunting!

Translated by