Need help in creating mask?
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Walter Roberson
2022 年 3 月 18 日
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 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!