Hello,
I've got some files dumped from radiographic software and apparently made up of raw data, 2 bytes per pixel.
Since I can't open them in any image editor (I tried GIMP, Photoshop, IrfanView and a few others), I'd like to know how to convert them into a lossless format (preferably but not necessarily limited to C++), like PNG (one specification of it handles 24bit so it'd be fine) or TIFF, which should natively support 16bit pixels.
Here's a sample file, it's just called "data" without any extension, it's just 13 MB:
http://s000.tinyupload.com/?file_id=08235066018321542051
In Processing 3.0 I've been suggested the following code, however I don't know where is the image size stored within the file nor why does its image size behave so that it had to be rounded (and I guess also lose/distort, even if just slightly, its native ratio).
What sets this raw data apart from other raw data that should be loaded just fine by image processing software?
Thank you very much
Allison
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
byte[] data;
public void settings() {
size(2336, 2928); // image is 2328 wide but round up to next nearest 32
}
public void setup() {
data = loadBytes("image.raw");
noSmooth();
noLoop();
}
public void draw() {
background(0);
loadPixels();
int index = 256; // skip metadata
for (int y = 0 ; y < height ; y++) {
for (int x = 0 ; x < width ; x++) {
int c = data[index + 1] & 0xff; // only using msbyte of 16 bit data
pixels[y * width + x] = (65536 + 256 + 1) * c; // greyscale
index += 2; // 16 bit colour = 2 bytes
}
}
updatePixels();
save("hand.png");
}
|