imagej

Recognizing Signed 16-bit RAW Files Based on Filename


I’ve been using ImageJ and noticed a helpful feature where dragging and dropping RAW files onto a dialog allows ImageJ to infer the file format and dimensions from the filename.

For example, when using a filename like example_u16_512x256.raw, ImageJ correctly identifies it as an unsigned 16-bit image with dimensions 512x256. However, I've encountered an issue when trying to use filenames for signed 16-bit images.

When I use filenames such as example_i16_512x256.raw, ImageJ incorrectly assumes it to be an unsigned 16-bit image instead of a signed 16-bit image. I have also tried other naming conventions like example_s16_512x256.raw and example_signed16_512x256.raw, but the same problem occurs.

Is there a specific filename convention I should use to ensure ImageJ correctly recognizes signed 16-bit RAW files?

Any guidance or suggestions would be greatly appreciated. Thank you!

Best regards,


Solution

  • I don't think there is an easy approach, if you want this to work per "drag and drop" however, below please find a short ImageJ-macro that imports signed 16bit raw images with file names such as "example_s16_512x256.raw":

    msg=" properly named, signed 16bit raw image";
    path=File.openDialog("Open a"+msg);
    s=File.getName(path);
    if (s.contains("s16")&&s.contains(".raw")) {
       w=s.substring(s.lastIndexOf("_")+1,s.lastIndexOf("x"));
       h=s.substring(s.lastIndexOf("x")+1,s.lastIndexOf("."));
       run("Raw...","open=[path] image=[16-bit Signed] width=&w height=&h");
    } else
       exit("Not a"+msg);
    

    You may assign a key-shortcut to the macro.