How can I save a multispectral image with a total of 7 color bands?

13 views (last 30 days)
I'm currently working with Landsat 8 imagery and I've had to do some geoprocessing on 7 out of the 11 bands. The bands I'm working with are coastal aerosol, blue, green, red, NIR, SWIR 1, and SWIR 2, labeled b1-b7, respectively. I'm doing topographic normalization on the 7 bands, and the correction method required I work on each band individually.
%%
%Run the cosine correction
fprintf('\nRunning Cosine Correction\n');
cos_b1=(double(b1)).*(cosZn./cosi);
cos_b2=(double(b2)).*(cosZn./cosi);
cos_b3=(double(b3)).*(cosZn./cosi);
cos_b4=(double(b4)).*(cosZn./cosi);
cos_b5=(double(b5)).*(cosZn./cosi);
cos_b6=(double(b6)).*(cosZn./cosi);
cos_b7=(double(b7)).*(cosZn./cosi);
%%
Now I want to combine cos_b1 through cos_b7 into a final image, so I compiled all the bands into an array...
%%
%Create an array from all bands
fprintf('\nCreating Final Image Array\n')
allBands=cat(7,cos_b1,cos_b2,cos_b3,cos_b4,cos_b5,cos_b6,cos_b7);
%%
But I am completely lost as to how to save the final array as an image; I truly need to be able to save it as an image that can be opened in ENVI. I have been able to open/view the individual bands in ENVI by saving them as .tif using the method below, however I'm unable to find an adequate way of combining all 7 bands and saving it as a single image.
%%
%Save all imagery
fprintf('\nSaving Imagery\n');
geotiffwrite('CosB1.tif',cos_b1,Rb1,'GeoKeyDirectoryTag',info_b1.GeoTIFFTags.GeoKeyDirectoryTag);
geotiffwrite('CosB2.tif',cos_b2,Rb2,'GeoKeyDirectoryTag',info_b2.GeoTIFFTags.GeoKeyDirectoryTag);
geotiffwrite('CosB3.tif',cos_b3,Rb3,'GeoKeyDirectoryTag',info_b3.GeoTIFFTags.GeoKeyDirectoryTag);
geotiffwrite('CosB4.tif',cos_b4,Rb4,'GeoKeyDirectoryTag',info_b4.GeoTIFFTags.GeoKeyDirectoryTag);
geotiffwrite('CosB5.tif',cos_b5,Rb5,'GeoKeyDirectoryTag',info_b5.GeoTIFFTags.GeoKeyDirectoryTag);
geotiffwrite('CosB6.tif',cos_b6,Rb6,'GeoKeyDirectoryTag',info_b6.GeoTIFFTags.GeoKeyDirectoryTag);
geotiffwrite('CosB7.tif',cos_b7,Rb7,'GeoKeyDirectoryTag',info_b7.GeoTIFFTags.GeoKeyDirectoryTag);
fprintf('\nCosine Correction Complete\n');
%%

Accepted Answer

Image Analyst
Image Analyst on 20 Mar 2016
Edited: Image Analyst on 20 Mar 2016
You can save the images in formats like tiff or png. ENVI can import those formats (plus a ton of others). Save one band per image. You'll have to assemble them into a single image once they're in ENVI, unless you want to use the TIFF class to create a multipage tiff file.
  1 Comment
Michael Dudley
Michael Dudley on 26 Mar 2016
I was able to open up each individual band in ArcMap & use the Composite Bands tool to save all of the bands into one final image. Thanks though!

Sign in to comment.

More Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!