|
Questions:
1. Is there a better way?
2. Is there a faster way?
I am working on a hyperspectral image that is 4096x512 by 187 bands.
I'm doing classification, but it is very slow because every time I want to classify a pixel, I need to go to 187 places in memory.
I am thinking that I need to reshape the image so that all the band data is right next to each other in memory, and then transpose it...
Here is some simple code for a small matrix that shows what I think I need to do:
mm = ones(2);
mm(:,:,2) = ones(2)*2;
mm(:,:,3) = ones(2)*3;
mm(:,:,4) = ones(2)*4;
dims = size(mm);
mr = reshape(mm,dims(1)*dims(2),dims(3))'
rm = reshape(mr,dims(2)*dims(3),dims(1))
This achieved the goal of putting the pixel bands together. However, it looks like a lot of work, and I have no idea what I'm doing to the computer memory.
Ideas for improvement welcomed.
Remember that the real image is much larger.
Thank you!
|