Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to change code to classify the whole picture? #1

Open
forestbat opened this issue Apr 3, 2024 · 5 comments
Open

How to change code to classify the whole picture? #1

forestbat opened this issue Apr 3, 2024 · 5 comments

Comments

@forestbat
Copy link

I want to classify the whole remote sensing picture not reference pixel,so I changed code:

    raster = rasterio.open(img_path, 'r')
    arr = raster.read()
    ref_count = 1
    ref_cord = [[round(arr.shape[1]), round(arr.shape[2])]]
    ……
    # ref_vect is reference pixel
    ref_vect = [[0 for x in range(bands)] for y in range(ref_count)]
    for i in range(ref_count):
        for j in range(bands):
            ref_vect[i][j] = arr[j, int(ref_cord[i][0])-1, int(ref_cord[i][1])-1]

But when I run the code,ref_vect is [[0, 0, 0, 0]] and r = ref_vect[j][nb] is all 0,so classified picture is all black.
How to specify ref_count,ref_cord and other variables to make the program work normally?

@cjaca
Copy link
Owner

cjaca commented Apr 3, 2024

Hi,
The algorithm itself is analyzing all 2d layers of the multilayer picture, not only one pixel.
Could you please elaborate more on what remote sensing picture do you have, or upload it here?

@forestbat
Copy link
Author

GF_6.zip
Thank you for your reply.
This picture come from GaoFen-1 satellite,and it has 4 bands.

@forestbat
Copy link
Author

3 days passed,do you have answer of the problem?

@cjaca
Copy link
Owner

cjaca commented Apr 8, 2024

Hi, I understand the problem now. I need some time to make it work, since it's not my daily business topic. I will notify you once It will be ready solution to analyze without reference pixels for less amount of layers

@lazyn1997
Copy link

lazyn1997 commented Jun 14, 2024

Your image has a black edge, all the channel values are 0, ref_vect is correct, and then the following formula will give the nan value, which does not satisfy the if condition, so it is classified to the background value, and the whole image is black.
image
You can get the following classification by arr = numpy.where(arr <= 0, 1e-6, arr) setting the arr ≤0 to a minimal value.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants