2d baseline removal from edges of image
Asked Answered
S

0

6

I have an image, say for example

z=double(rgb2gray(imread('onion.png')));
z=z./max(z(:));
imagesc(z)

enter image description here

However, ~10 pixels from all sides I get a different baseline that I'd like to remove. The baseline is probably because of gain artifact of the pixels at the edges.

Artificially, I can create that effect as follows:

m=zeros(size(z));
m(1,:)=5; m(end,:)=5;
m(:,1)=5; m(:,end)=5;
m=conv2(m,fspecial('gaussian',15,3),'same');

enter image description here

Such that the image I actually get is this one:

imagesc(z+m); % I assume the effect is additive but I dont know that

enter image description here

I'd like to remove that baseline frame and retain the original info in the edges of that image. Any ideas?

Some of the images has very smooth features, so I've tried to get rid of the "frame", by cropping the sides and extrapolate, but it's not doing a good job.

Stern answered 11/10, 2018 at 23:25 Comment(9)
While I do not know what is the source of the error you have (depends on the hardware/experimetn/source of the image) the effect you describe is very close to what happens in any photon detector (cameras ,X-ray detectors, etc). Generally this effect is removed with flat field correction, that requires you to get more data (the code itself is trivial, as you can see). Is this your case?Freda
this is very similar, however I only have the images as is, without access to any calibration data to correct for dark field, otherwise it is pretty trivial. In addition it looks like it's some weird inherent pixel cross-talk at the edges that happens. At least it looks consistent from one image to the next, so I can take avg differences. But the images are not identical, so that's an approximation...Stern
Would it be possible for you to post some originals, rather than your demo-data?Freda
here's one of these images (mat file)... the effect is more notiable on the left side filedropper.com/nzzStern
@bla: Is the effect only occurring on the lower left side of that image. I don't see much going on anywhere else.Quacksalver
this is only one image. I choose what I think is the easiest image to handle, but it depends on the image, I can attach more,. generally speaking it can happen in all edges, sometimes in one or two etc...Stern
@Stern I think that as is, its not solvable. Mainly because we don't know whats in the images, that effect could as well be data. Your best bet is 1)getting better data 2)adding strong constrains on what is information and what is not 3)discovering the cause of that effect and modelling it to remove it.Freda
Did you ever solve this?Spill
I did find a couple of approximate solutions, but forgot about the question ever since, I can try to sketch up the solutions. In short, i was did SVD over all the images I have that had that issue, and localized the contribution of the edges. In a different solution I found the baseline per row and column and removed it with local polynomial fits of different orders, a higher order fit for the neighborhood of the effect (say 10 pixels from each edge) vs a low order fit from the a larger sampling length (say 200 pixels from each edge). Neither solutions are perfect, but better than before...Stern

© 2022 - 2024 — McMap. All rights reserved.