How can I write a multi-band image in jp2 format?

조회 수: 13 (최근 30일)
Thomas Flick
Thomas Flick 2019년 11월 11일
댓글: Thomas Flick 2019년 11월 18일
I would like to compress a multi-band image with JPEG-2000 compression. I tried the following lines but got an error, "4 channels not supported for JP2 files. Only 1 and 3 channels are supported."
test = zeros(10,10,4,'uint8'); imwrite(test,'test.jp2');
Is there a workaround for this problem? JPEG-2000 compresses each band individually so I don't understand the limitation.

답변 (1개)

Urmila Rajpurohith
Urmila Rajpurohith 2019년 11월 15일
As mentioned in the error jp2 files support either 1 channel or 3 channels.
To write multi-band image in jp2 format you can follow below workflow.
First you can extract individual channel and then convert them to jp2 format using “imwrite function and you can read them using “imread function and then you can stack all 4 bands and write them to .tiff format using imwrite function
(or)
You can use “multibandwrite” function to save the multiband data.
But in this method, you will be able to save multichannel image & you will not be able to achieve the jp2 compression.
You can refer to the below documentation for more information on how to use “multibandwrite” function.
  댓글 수: 1
Thomas Flick
Thomas Flick 2019년 11월 18일
Yes, I saw the multibandwrite function, but I need to achieve jp2 compression.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by