Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pentax K1 file in APS-C mode has wrong raw crop #3519

Closed
heckflosse opened this issue Dec 2, 2016 · 17 comments
Closed

Pentax K1 file in APS-C mode has wrong raw crop #3519

heckflosse opened this issue Dec 2, 2016 · 17 comments
Labels
scope: file format Camera or image file formats

Comments

@heckflosse
Copy link
Collaborator

Pentax K1 files in APS-C mode have wrong raw crop. There's a coloured vertical line at right border.
Pentax K1 APS-C file
The file is a pixelshift file. I don't know if that matters. The issue is reproducible in master branch which reads only the first frame of that file and also in pixelshift branch (tried with all 4 frames).

@iliasg Do you have an idea?

@heckflosse heckflosse added the scope: file format Camera or image file formats label Dec 2, 2016
@iliasg
Copy link
Collaborator

iliasg commented Dec 3, 2016

A few things go wrong with this

  • Dcraw.cc reads the size of the (full uncropped) raw_frame then applies raw_crop.
    In camconst.json we have defined only the FF raw crop so here we have
    raw_size = 4832x3238
    raw_crop in camconst.json is "raw_crop": [ 6, 18, 7376, 4932 ],
    DNG raw_crop tag gives 18 0 3238 4832 (vertical first ) which is translated in camconst.json
    "raw_crop": [ 0, 18, 4832, 3220 ], in absolute size or [ 0, 18, 0, 0 ] in relative
    RT (used to crash in such cases some time ago) but now just clips at the raw_size but looks like it missed the left_border (6) so tries to fill the 6 missing columns .. Demosaic cuts 4 of them and the remaining is 2 garbage columns at the right ..

  • Dcraw has no raw_crop data for K-1

  • The DNG raw crop tag should have higher priority than camconst.json if we (or Dcraw.c) has no related adobe_coeff (make, model) .. in dcraw.cc .. which is non existent in current dcraw.cc
    I thought that this is the case (DNG has higher priority) and this is the reason I used the same raw_crop as defined in DNG tags in order to both DNGs and PEFs have same size ..

  • We have not the ability to use multiple raw frames for each model in camconst.json ..
    Dcraw uses the raw_frame size to define multiple raw crops i.e. if raw_size (width, height or both) is X then raw_crop is Y

I think the correct would be to add multiple frame support in camconst.json
The easy and dirty solution is to add in dcraw.cc the missing lines .. and remove raw_crop from camconst.json

@8746 +
if (width = 7392 && !strncmp(model,"K-1",3))
    { left_margin = 6; width  = 7376; top_margin = 18; }
if (width = 4832 && !strncmp(model,"K-1",3))
     top_margin = 18;

@Hombre57
Copy link
Collaborator

Hombre57 commented Dec 3, 2016

@iliasg When you say "multiple frame support", all frames from a single file have the same size, of course. This file has been shot in APS-C mode, hence the difference in size for all its sub-images.

@iliasg
Copy link
Collaborator

iliasg commented Dec 3, 2016

@Hombre57 it should be "multiple frame_size support" for each model (no relation with multiframe raw files like pixelshift)
i.e support defining the raw_crop for both FF and APS-C in Pentax FFs or Nikon FFs which have up to 3 different crop modes (D810), Sony FF, Olympus normal and Hires modes (E-M5II has 16Mp and 64Mp raw sizes,).
Up to now we either leave this on Dcraw if it supports the model (where the sizes are sometimes suboptimal) or for Sony FFs we use the relative raw_crop in camonst.json (i.e we only define the borders) as it happens that both FF & APS-C modes use the same borders.
With K-1 and Olympus the borders do not match and there is the problem ..

@Hombre57
Copy link
Collaborator

Hombre57 commented Dec 3, 2016

@iliasg Ok, I understand. Pentax K-1 has 3 crop mode in fact. If you don't mind, could you also have a look at the 1:1 crop ratio ?

https://filebin.net/mdlhop60w346dgs2/PENTAX_K-1_1-1Crop.PEF

@Hombre57
Copy link
Collaborator

Hombre57 commented Dec 4, 2016

As Ingo told me on IRC, that 1:1 raw file has a cropped jpeg embedded image but a Full Frame raw image, so there's no 3 real raw crop size. I should have opened that file in RT first instead of guessing... (I've never shot in this crop ratio)

@iliasg
Copy link
Collaborator

iliasg commented Dec 30, 2016

@heckflosse @Beep6581
I think the code at
#3519 (comment)
should be commited or else I have to try with a bit different "raw_crop" in camconst.json to (not optimally) cover both FF and APS-C cases .. ;)

@iliasg iliasg mentioned this issue Jan 4, 2017
26 tasks
@heckflosse
Copy link
Collaborator Author

heckflosse commented Jan 9, 2017

@Hombre57 Can you please supply an APS-C size PEF file from K-1? We need to solve the issue for DNG and PEF before pushing.

@Hombre57
Copy link
Collaborator

Hombre57 commented Jan 9, 2017

@heckflosse RT is crashing here so I can't check the shot size, however considering the file size it should be APS-C. Do not publish or share.

https://filebin.net/3m926h3eqidis75m

@heckflosse
Copy link
Collaborator Author

@Hombre57 Can you test this patch with full and aps-c format pef and dng from k-1?

@Hombre57
Copy link
Collaborator

Sure.

@heckflosse
Copy link
Collaborator Author

@Hombre57 Great! If it works fine in your tests (here it works fine) I can push it for rt5 if there are no objections.

@Hombre57
Copy link
Collaborator

Yes, works fine with FF & APS-C PEF image, and for FF DNG image. I don't have APS-C DNG image but I guess it works fine too ;). +1 for committing.

@heckflosse
Copy link
Collaborator Author

I tested with APS-C DNG image I got from you. Also works fine. Will commit now. Thanks for testing 👍

@heckflosse
Copy link
Collaborator Author

@Hombre57 Can you upload a raw file from K-1 shot in square mode? I want to test how auto distortion correction behaves for that case (comparing full size crop to square jpeg preview)

@Hombre57
Copy link
Collaborator

Here is a PEF file in 1:1 crop format https://filebin.net/wsqk7i85uksgs0g5 , but I don't know if lens correction was enabled. If not, I won't be able to take a new one until my K-1 come back from the repair service.

@heckflosse
Copy link
Collaborator Author

heckflosse commented Jan 10, 2017

@Hombre57 Does not matter whether lens correction is enabled. I just want to try whether the aut. lens correction algo does not crash in that case.

@heckflosse
Copy link
Collaborator Author

@Hombre57 Just tested. No crash, no correction, fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: file format Camera or image file formats
Projects
None yet
Development

No branches or pull requests

3 participants