jpeg2000 compression of hyperspectral image data (imwrite not working)

4 Ansichten (letzte 30 Tage)
I am trying to apply add noise to a hyperspectral image data matrix(m-n-layers) by applying jpeg2000 compression on each of the layers saparately. So we can't use it like a nomal .jgp or .png image. I tried the imwrite scheme in loop format (not actual code here),
a = image(:,:,1); % a can only be a gray scale or rgb or an indexed data as I remember
imwrite(a,'image1.jpg', 'Compression','jpeg','CompressionRatio',10);
% the upper line threw an error that "not valid arguments"
% neither the next line work
imwrite(a,'image1.jpg','Mode','lossy','CompressionRatio',10); %according to the documentation
%the syntax doesn't allow the output to be a data matrix like the input itself too
imwrite(a,imageNoise(:,:,1), 'Compression','jpeg','CompressionRatio',10);
, but apparantely it allows compression for HDF format only. I want to store the output in a data matrix format(m-n-layers) only (compression applied layerwise). Can you suggest me any alternate way to apply jpeg2000 compression without imwrite. Thanks in advance.
  4 Kommentare
Walter Roberson
Walter Roberson am 7 Apr. 2019
'Compression' as an option is available only for HDF4 and TIFF.
'CompressionRatio' as an option is available only for JPEG2000. To get JPEG2000 you need to use the 'jp2' option (before the keyword/value pairs), or you need to use 'jp2' or 'jpx' as the file extension. JPEG2000 options are not available for .jpeg file extension.
Pushkar Khatri
Pushkar Khatri am 8 Apr. 2019
Bearbeitet: Pushkar Khatri am 8 Apr. 2019
So I ran this code
a = img(:,:,190); %190th layer
a_8Bit = uint8(255 * mat2gray(a));
imwrite(a_8bit,'imageb.jp2','CompressionRatio',10)
%scaled the layer of image to uint8
It worked! the output file is created as imageb.jp2 file
I have to create the modiefied img data matrix. I can't just store .jp2 files. I'll have to run this imwrite function 190 times manually. Can you suggest me an efficient way so that i can run it in one loop for all the layers(applying same compression ratio to each layer) and store in one place, then I will read the images in data matrix format?
Thanks a lot

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by