Need help in creating mask?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rahul Shah
am 18 Mär. 2022
Beantwortet: Walter Roberson
am 18 Mär. 2022
I have matix of size 7071X7801 which contains the pixel values of image (this is Landsat 5 image) and there are 0 values at edges of image
So, I want to select 9 fixed matrices to create a mask based on pixed values by excluding 0 values.
Right now, I am reading one small matrix 11X11 pixel size like:
[A, R] = geotiffread('...tif'); %reading .tif image
%(200,1414) this center for below matrix
i0 = 200;
j0 = 1414; %center of small 11X11 matrix
[row, col] = size(A);
A_small = A((i0-5):(i0+5),(j0-5):(j0+5));
Now, I want to automate this process by shifting this matrix 1000 pixel and select new 11X11 size matrix. So, can you guys give me any thoughts, how can I proceed from here?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 18 Mär. 2022
blockproc() need not return an array the same size as the nominal input window. It would be valid, for example, to tell it you want a 1000 x 1000 window, but then when you get the data, extract only the first 11 x 11 pixels from it.
But if it is just a matter of removing the 0 pixels, then you can
horzmask = any(TheImage, 1);
hfirst = find(horzmask, 1, 'first');
hlast = find(horzmask, 1, 'last');
vertmask = any(TheImage, 2);
vfirst = find(vertmask, 1, 'first');
vlast = find(vertmask, 1, 'last');
subset = TheImage(vfirst:vlast, hfirst:hlast);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!