如何使用Matlab从星系FITS图像中删除星星和其他物体?(How to remove stars and other objects from a galaxy FITS image using Matlab?)

我有以下适合格式的图像。 我想使用matlab从该图像中删除所有星星和其他较小的点。

我执行了以下matlab操作来删除其中的星星。

I = imread('NGC_0253.jpg'); if size(I,3)==3 I=rgb2gray(I); end K = imcomplement(I); L = I-K; M = medfilt2(L); imshow(M)

我得到这样的图像:

我也尝试以下方法:

I = imread('NGC_0253.jpg'); if size(I,3)==3 I=rgb2gray(I); end K = imcomplement(I); L = I-K; M = bwareaopen(L,1000); N = medfilt2(M); imshow(N)

但它也不满足我:

这不是我的目标。 我的目标是从图像中删除所有星星。

那么,我应该怎么做才能从图像中删除所有留下星系完整的恒星?

I have the following image in fits format. I want to remove all the stars and other smaller dots from that image using matlab.

I performed the following matlab operations to remove stars in it.

I = imread('NGC_0253.jpg'); if size(I,3)==3 I=rgb2gray(I); end K = imcomplement(I); L = I-K; M = medfilt2(L); imshow(M)

I am getting image like this:

I also try the following:

I = imread('NGC_0253.jpg'); if size(I,3)==3 I=rgb2gray(I); end K = imcomplement(I); L = I-K; M = bwareaopen(L,1000); N = medfilt2(M); imshow(N)

but it also does not satisfy me:

Which is not my objective. My objective is to remove all the stars from the image.

So, What should I do to remove all the stars leaving the galaxy intact from the image?

最满意答案

通过使用bwareaopen我得到了一个好结果。 (我使用您的第二个图像作为输入,因此您可以保留代码的第一部分)

I = imread('NGC_0253.jpg'); I = im2bw(I,0.5); %the second parameter correspond to the threshold ∈ [0-1] I = ~bwareaopen(~I,400); %where 400 = the minimal number of connected pixel needed to not be removed. imshow(I)

INPUT:

在此处输入图像描述

OUTPUT:

在此处输入图像描述

改进:

更准确地说,计算椭圆的参数会很有用。

在此处输入图像描述

为此,您可以使用fileexchange上提供的fit_ellipse函数。

Iedge = edge(mat2gray(I),'Canny'); [x,y] = find(Iedge'); hold on A = fit_ellipse(x,y,h);

By using bwareaopen I get a good result. (I use your second image as input, so you can keep the first part of your code)

I = imread('NGC_0253.jpg'); I = im2bw(I,0.5); %the second parameter correspond to the threshold ∈ [0-1] I = ~bwareaopen(~I,400); %where 400 = the minimal number of connected pixel needed to not be removed. imshow(I)

INPUT:

enter image description here

OUTPUT:

enter image description here

Improvement:

To be more precise it can be useful to compute the parameters of the ellipse.

enter image description here

To do that you can use the function fit_ellipse available on fileexchange.

Iedge = edge(mat2gray(I),'Canny'); [x,y] = find(Iedge'); hold on A = fit_ellipse(x,y,h);

更多推荐