Reputation: 23
I've got some weird images I'm getting from some hardware at work. They're from this weird piece of hardware that has multiple images being stitched together and stored as raw images. Think of one of those computer security displays with four images displayed at once. Basically, it's like that. And then they're being stored as raw images. Annnnd, there's no documentation for this old piece of junk at all.
I tried to write an extractor to split the images into separate raw files. But the raw image software I used to try and read the image I extracted as a test indicates that it's corrupted. I'm currently thinking that even though it's just raw data, there's supposed to be a file header. But no matter how hard I look, I can't seem to find a definition for a raw image file online. I see that there's a ton of different raw image file types, but I can't even find definitions for those.
Any advice for me?
edit: After rereading this, I don't think I'm being very clear. I have made a supposition in reading in my raw file I wish to split, the supposition is that I believe there is no header in the file, and start copying data for the first image I am extracting with the first byte of data. I also make the same supposition in the image file I am writing out, and I write no header as I'm copying out the image. I believe my supposition about no headers is incorrect and am asking for clarification on that. To help elucidate this, I am including the test code I wrote:
#include <stdio.h>
#include <string.h>
using namespace std;
//size of individual image
int width = 400;
int height = 400;
//size of input image
int inputWidth = 1600;
int inputHeight = 8000;
int offset = 16;
char strInputFile[] = "captured.raw";
char strOutputFile[] = "extracted.raw";
int main()
{
printf( "Hi\n" );
FILE* pInput = NULL;
FILE* pOutput = NULL;
char* buf = new char[width];
memset( buf, 0, width );
pInput = fopen( strInputFile,"rb" );
pOutput = fopen( strOutputFile,"wb" );
if( pInput && pOutput )
{
for( int i = 0; i < height; i++ )
{
//read in a row of pixels
fread( buf, 1, width, pInput );
//write out the row of pixels
fwrite( buf, 1, width, pOutput );
//move the file pointer forward to the next row of pixels
fseek( pInput, inputWidth - width, SEEK_CUR );
}
}
fclose( pInput );
fclose( pOutput );
return 0;
}
Upvotes: 2
Views: 25571
Reputation: 9587
Seeing as how heterogeneous the raw image formats can be, I would suggest the following approach:
Upvotes: 2
Reputation: 15813
Modern raw images are in various formats with headers and metadata, usually compressed, and sometimes compressed with lossy compression. Many raw formats are not publicly documented. FreeImage can be used to read raw images from many digital cameras.
Older security systems and other cameras may store raw data as just that -- a set of numbers that make up the image and nothing else. This may or may not be compressed, and it may or may not be RGB values.
Without documentation, you may have to examine the data of the files and use the time-honored programming technique of trial and error. Or get new cameras. :-)
Upvotes: 1
Reputation: 93410
Have you read about raw image format?
This thread is a must-read: RAW Image file - what format is my data in?
Upvotes: 1