ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 JPEG2000 raw pixels without metadata

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
JanB Posted - Mar 17 2024 : 11:06:02
Hello!

I try to access the pixel data of jp2 file. The jp2 file has additional xml informations at the beginning of the file.
Is there any way to access only the RGBA values of the jp2 file without the xml informations at the beginning?

Here 2 attempt which didn't seem to work:

var
  ABmp: TIEBitmap;
  ABytes, CurrBytePos: PByte;
  ARow: Integer;
  ASize: Int64;
begin
  ABmp := TIEBitmap.Create;
  ABytes := nil;
  try
    ABmp.Read('T33UUS_20240303T100819_TCI_10m.jp2');
    ASize := ABmp.Rowlen * ABmp.Height;
    GetMem(ABytes, ASize);
    CurrBytePos := ABytes;
    for ARow := 0 to ABmp.Height - 1 do begin
      Move(ABmp.ScanLine[0]^, CurrBytePos^, ABmp.Rowlen);
      inc(CurrBytePos, ABmp.Rowlen);
    end;
  finally
    ABmp.Free;
    if (Assigned(ABytes)) then
      FreeMem(ABytes);
  end;
end;



var
  ABmp: TIEBitmap;
  ABytes, CurrBytePos: PByte;
  ARow, ACol: Integer;
  ASize: Int64;
  ARGBA: TRGBA,
begin
  ABmp := TIEBitmap.Create;
  ABytes := nil;
  try
    ABmp.Read('T33UUS_20240303T100819_TCI_10m.jp2');
    ASize := ABmp.Rowlen * ABmp.Height;
    GetMem(ABytes, ASize);
    CurrBytePos := ABytes;
    for ARow := 0 to ABmp.Height - 1 do begin
      for ACol := 0 to ABmp.Width - 1 do begin
        ARGBA := AImage.IEBitmap.Pixels_ie32RGB[ACol, ARow];
        PRGBA(CurrBytePos)^ := ARGBA;
        inc(CurrBytePos, SizeOf(TRGBA));
      end;
    end;
  finally
    ABmp.Free;
    if (Assigned(ABytes)) then
      FreeMem(ABytes);
  end;
end;


I checked out the EncapsulateFromMemory method as well, but it seems to behave as the written code above.

Example File (128MB) so I uploaded it somewhere else:
https://www.file-upload.net/download-15285284/T33UUS_20240303T100819_TCI_10m.jp2.html

In additional I have to work with the raw pixels to perform other calculation after reading the files and I try to keep it as fast as possible. So the pixel data has to stay as they are, no transformations, that might change these values.

How can I access the raw pixel data from jp2 file?

Regards
Jan
2   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 17 2024 : 16:10:58
Hi

To avoid any pixel conversions, you should also be using:

Abmp.Params.NativePixelFormat := True;

https://www.imageen.com/help/TIOParams.NativePixelFormat.html

Nigel
Xequte Software
www.imageen.com
JanB Posted - Mar 17 2024 : 13:29:18
I checked my 2nd approach and it uses the wrong pixel data it should be Pixels_ie24RGB.

var
  ABmp: TIEBitmap;
  ABytes, CurrBytePos: PByte;
  ARow, ACol: Integer;
  ASize: Int64;
begin
  ABmp := TIEBitmap.Create;
  ABytes := nil;
  try
    ABmp.Read('T33UUS_20240303T100819_TCI_10m.jp2');
    ASize := ABmp.Rowlen * ABmp.Height;
    GetMem(ABytes, ASize);
    CurrBytePos := ABytes;
    for ARow := 0 to ABmp.Height - 1 do begin
      for ACol := 0 to ABmp.Width - 1 do begin
        case (ABmp.PixelFormat) of
          ie32RGB: begin
            PRGBA(CurrBytePos)^ := ABmp.Pixels_ie32RGB[ACol, ARow];
            inc(CurrBytePos, SizeOf(TRGBA));
          end; 
          ie24RGB: begin
            PRGB(CurrBytePos)^ := ABmp.Pixels_ie24RGB[ACol, ARow];
            inc(CurrBytePos, SizeOf(TRGB));
          end; 
        end;
      end;
    end;
  finally
    ABmp.Free;
    if (Assigned(ABytes)) then
      FreeMem(ABytes);
  end;
end;