how to save hyperspectral image array to image in matlab?

8 views (last 30 days)
hello everyone, i have some questions about processing hyperspectral image using matlab,and they are as follows:
(1) i use multibandread function to read one hyperspectral image and an image array is obtained. Then how can i write the array to image, such "tif","jpg" ? Because hyperspectral image has many bands, so imwrite function is useless. multibandwrite function can be used to write the array, however the result is binary image not tif or jpg.
(2) i randomly select 3 bands from the hyperspectral image array and want to display one color image. I have done this work according to the strategy in rgb image, but the composite rgb hyperspectral image cannot display. what's wrong?
  2 Comments
Walter Roberson
Walter Roberson on 26 Mar 2014
If you had (say) 4 bands, what would you expect the image file to look like? You wold expect that in such a case it would render as CMYK ?
Wind Cloud
Wind Cloud on 26 Mar 2014
i want to get similar results as the function "imwrite", which means the final image type is "*.tif","*.jpg",etc. My initial purpose is to cut the whole image into many patches with the same size and same bands, and then write the image array corresponding to each patch to image with the type "*.tif","*.jpg",etc.This work is easy for rgb image with three bands using the function "imwrite".

Sign in to comment.

Answers (3)

Image Analyst
Image Analyst on 26 Mar 2014
You can save the variable with save() into a .mat file if all you want to do with it in the future is to read it back into MATLAB again. Of you can use multibandwrite()

Walter Roberson
Walter Roberson on 26 Mar 2014
When you use imwrite() the expectation is that you are creating an image intended to be rendered for human eyes -- black and white, or greyscale, or pseudocolor, or true color (RGB) or CYMK. imwrite() is not intended for storing multiple bands.
.jpg files cannot store more than 3 bands.
.tiff files can store 4 bands fairly directly and will believe that it is a CMYK image.
If you use the TIFF class then you can create "tiles" and "strips". It also supports a "directory" and "subdirectories" that can be used to write multiple images or data sets to a TIFF file.
  2 Comments
Wind Cloud
Wind Cloud on 27 Mar 2014
in fact, TIFF class cannot solve my problem. anyway, thanks!
Jurgen
Jurgen on 27 Mar 2014
Actually TIFF can store your hyperspectral image as one file. Just don't expect to open it in standard windows image viewer.

Sign in to comment.


Cong Huynh
Cong Huynh on 14 Aug 2015
To load and save multispectral images (consisting of pairs of .hdr and .fla files), you could use the Scyllarus hyperspectral image processing toolbox. The MATLAB version of this toolbox is available for non-commercial use and can be downloaded from http://scyllarus.research.nicta.com.au/
The functions to look at are FLARead and FLAWrite under src/io. With these functions you can read from and write to the .fla format (ENVI-compatible), rather than any colour image format. Alternatively you can save the image to a .mat file but this option usually produces a much larger image.
  1 Comment
yanjie qi
yanjie qi on 9 Mar 2016
I have tried the tool box,and I use matlab R2014a. However, most of the function I can't use them, like FLAread... and
>> G = data2graph(xdata); 未定义与 'double' 类型的输入参数相对应的函数 'data2graph'。

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!