Read Fuji RAF in CFA

Hello,
I am trying to read RAF files in CFA (equivalent of dcraw -v -T -4 -o 0 -D -t 0 -k 0 -H 1). I'm using this piece of code which is working well with other pictures:

	raw->params.user_flip = 0;		/* no flip                                 */
	raw->params.output_color = 0;		/* output colorspace, 0=raw, 1=sRGB, 2=Adobe, 3=Wide, 4=ProPhoto, 5=XYZ*/
 
	raw_width = raw->sizes.raw_width;
	width = raw->sizes.width;
	height = raw->sizes.height;
	npixels = width * height;	
	left_margin = raw->rawdata.sizes.left_margin;
	top_margin = raw->rawdata.sizes.top_margin;
 
        [...]
 
	int offset = raw_width * top_margin + left_margin;	
	i = 0;
	for (row = 0; row < height; row++){
		for (col = 0; col < width; col++){
			buf[i++] = (WORD)raw->rawdata.raw_image[offset + col + (raw_width * row)] ;
		}
	}

I know that Fuji are different and need to be opened at 45deg, but I do not know how to handle this.
Width and height have right values of rotated image.

Please, could you give me a hand.
Regards,

Forums: 

Fuji is not different, raw

Fuji is not different, raw access is the same.
The only difference is not 1:1 aspect ratio on some (very) old Fuji cameras.

BTW, please use raw_width/raw_height in your code, not width/heigh (and not iwidth/iheight)

-- Alex Tutubalin @LibRaw LLC

Thank you for the tip about

Thank you for the tip about only using raw_width and raw_height.
But by doing like this I have:
http://hpics.li/d461ad2
width and height are not good at all ...
All other images seem to work correctly.

Yes, Fuji S2/S3/S5 (and, may

Yes, Fuji S2/S3/S5 (and, may be, other Super-CCD cameras) use different aspect ratio, not 1:1

The rotate trick is to scale 1:1.41 images to square pixels using only integer math.

-- Alex Tutubalin @LibRaw LLC

OK.

OK.
Fuji are kind of tricky. Thank you for all your advices.
But by using raw_width and raw_height I have black frames I do not want. It was the reason I used width and height.
But apparently this is a problem for Fuji !!

EDIT: and I also have
==21644== Invalid read of size 2 in the line
buf[i++] = raw->rawdata.raw_image[offset + col + (raw_width * row)] ;

EDIT2: Sorry, this is only because offset is not necessary anymore with raw_width and raw_height.

Correct me if I'm not right,

Correct me if I'm not right, but it was not working because in RAF file you have left and right frame. But in others, like CR2 you have left and top (If I well remember).
So how we remove frames if they aren't in the same place ?

Sorry, cannot understand your

Sorry, cannot understand your question.
Initially your question was about 'dcraw -D' so document mode, so full access to raw with black frame.

-- Alex Tutubalin @LibRaw LLC

What I mean, is when I run

What I mean, is when I run this:
dcraw -v -T -4 -o 0 -D -t 0 -k 0 -H 1 image.CR2

I do not have any black frames, and this is the behavior I'm trying to reproduce. I've had this with the use of width and height (but RAF files was buggy).

By the way, many thanks for helping me!!

I think I should go ahead.

I think I should go ahead because I did understand.

Thanks for your help with Fuji

Hello Alex.

Hello Alex.

I've correctly opened RAF file without frames thanks to you.
Now I have to apply the scale to transform my picture from this http://hpics.li/ffe7b4f to this http://hpics.li/f653896.

You say that 45deg rotation allows to use only integer math for the scale? What is the function in dcraw (or libraw) doing that ?
fuji_rotate() is only use in the case of debayered data to go back to normal picture.

Cheers

There is no separate LibRaw

There is no separate LibRaw call to rotate fuji data.

Rotation is performed within LibRaw::raw2image_ex call (which copies data from raw_image array to image[][4] array)

-- Alex Tutubalin @LibRaw LLC

Sorry for misinformation.

Sorry for misinformation.

There is LibRaw::copy_fuji_uncropped() that do the trick.

If you do not use image[][4] array, you may copy-paste it and adopt to your needs.

-- Alex Tutubalin @LibRaw LLC

Damn, no C API :).

Damn, no C API :).

I have to take a look in dcraw.c to see how it is done .... But this code is no easily readable :).

Best regards