Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Seeking Best Hyperspectral-Image Reshaping (Planer to pixel interleaved) for Speed

Subject: Seeking Best Hyperspectral-Image Reshaping (Planer to pixel interleaved) for Speed

From: Pat Finder

Date: 15 May, 2009 11:49:02

Message: 1 of 1

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!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us