Is it possible have something like video crop mode for photos?

Started by Chimico Pazzo, April 10, 2019, 01:05:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chimico Pazzo

Hi forum!

First thing: I am sorry for my english.. I hope to explain me good... Be patient!

Like I write in the object, if there was the possibility of taking raw photographs cropping central part of sensor, it would be interesting in astrophotography because it would allow smaller files to be processed.

Is it possible?

Thank you for this great job called Magic Lantern!

Chimico Pazzo

Levas

Something like that is possible, but it is called raw video :D

I don't know which Canon camera you have, but if there is Magic Lantern for it, you can use raw video for astro.
In raw video you can select how many pixels you want to record from your sensor.
If you use Canon liveview 'zoom' mode, you can select a centre crop from your sensor.
Depending on the Canon video mode you are in, you get 30, 25 or 24 frames per second, which can be tweaked with another future in Magic Lantern called 'FPS override' to a lower number.
When you use this, you actually get what you want, many raw photos of a specific resolution from the centre of your sensor at a speed of 30, 25 or 24 frames per second (or less with FPS-override).
You end up with only one file on your memory card, but you can use MLV_app to extract all frames out of it in DNG format.

Which camera do you have ?

I've played a little with astro and raw video and a cheap Samyang 500mm mirror lens (which has no sharpness at all  :P ) and some teleconverters.
These are stacked images of Saturn and Jupiter and three of his moons.
I don't have a tracker, shot from a static tripod with the Samyang and teleconverter and Magic Lantern raw video and some auto aligning and stacking software.



Chimico Pazzo

I know the raw video (I have a 550D and 6D) and I use it for planetary image and work very well!!
But my hope is to have crop mode on long exposure photos: it's hard and long process, for example, 200 or more raw file of 20mb (and others for dark frame, flat frame...) and often we crop final image...
Would be better have a cropped frame during acquiring light frame!

(An example of video raw on moon with SC 8" telescope)





Levas

Nice details in those moon shots.
For as far as I know there is still no option in cropping resolution in silent picture module.
So raw video is probably your only chance, how long do you need these exposures to be ?
Are we talking about seconds, or a bit less.
Have you checked FPS override option and see how far you could go, could you go to for example slow it down to 1 fps ?

I know that about 2.5 fps is possible, giving exposure time of 0.4 seconds, camera menu reacts a little slow, but it works.

Chimico Pazzo

Thank you!

The best thing is a central crop like 50-30% (possibly both :D) of frame with bulb timer. :P

The problem about low fps in video crop mode is temerature: the display/screen of camera is always on during record and its heat create termal noise...

Walter Schulz

Quote from: Chimico Pazzo on April 11, 2019, 12:05:32 PM
The problem about low fps in video crop mode is temerature: the display/screen of camera is always on during record and its heat create termal noise...

Try Prefs tab -> Powersave in Liveview -> Enable while recording ON & Turn off LCD after 5 sec

Kharak

I have no experience with astrophotography.

But would MRaw or Sraw work for decreased sizes? not sure how the sharpness is though. Should be better than a HD frame by frame though.
once you go raw you never go back

a1ex

The full-res silent picture mode can do long exposures (it's limited to 15 seconds in mainline, but there is a patch available for bypassing this limit), so... it's technically possible to implement, as long as you use our DNG format (not CR2).

Just not a priority for me right now.

It's also possible (and maybe easier) to crop the full-res CR2/DNG files in post. I'd try something along these lines:
- extract the Bayer raw data (dcraw -4 -E *.CR2) -> 16-bit PGM files containing unmodified 14-bit raw data
- crop the files with ImageMagick (mogrify -crop 1000x1000+500+500 *.pgm)
- use pgm2dng to convert the PGM files to DNG

Slightly related: the full-res silent picture code can also capture dark frames; it's not implemented either, but if you run it outside LiveView, that's exactly what you are going to get.

Chimico Pazzo

Quote from: Walter Schulz on April 11, 2019, 12:39:54 PM
Try Prefs tab -> Powersave in Liveview -> Enable while recording ON & Turn off LCD after 5 sec

I admit, I never considered this menu. I will try this way, thank you!

Quote from: Kharak on April 11, 2019, 12:44:43 PM
I have no experience with astrophotography.

But would MRaw or Sraw work for decreased sizes? not sure how the sharpness is though. Should be better than a HD frame by frame though.

In astrophotography you need the best raw you can. Are considered unusable Mraw and Sraw
Thank you for your partecipation!

Quote from: a1ex on April 11, 2019, 12:53:35 PM
The full-res silent picture mode can do long exposures (it's limited to 15 seconds in mainline, but there is a patch available for bypassing this limit), so... it's technically possible to implement, as long as you use our DNG format (not CR2).

Just not a priority for me right now.

It's also possible (and maybe easier) to crop the full-res CR2/DNG files in post. I'd try something along these lines:
- extract the Bayer raw data (dcraw -4 -E *.CR2) -> 16-bit PGM files containing unmodified 14-bit raw data
- crop the files with ImageMagick (mogrify -crop 1000x1000+500+500 *.pgm)
- use pgm2dng to convert the PGM files to DNG

Slightly related: the full-res silent picture code can also capture dark frames; it's not implemented either, but if you run it outside LiveView, that's exactly what you are going to get.

I am not sure to understand all... DNG are no problem, I will try silent picture. Is it possible use silent picture with intervalometer?


Mean time I will go to study "silent picture" and "powersave" menu!

Walter Schulz

Quote from: Chimico Pazzo on April 11, 2019, 02:43:47 PM
Is it possible use silent picture with intervalometer?

Sure, widely used. There are 2 caveats: Silent pic is coded to use half-shutter and intervalometer default setting is using this trigger, too. You have to change intervalometer trigger. See https://wiki.magiclantern.fm/camera_help#intervalometer
And because FRSP feature (in it's current version) takes several seconds to store a pic you have to consider this duration fo your intervalometer setting.

Chimico Pazzo

Great! Really great!!
I have tried and everything work:series of shots in silent picture with live view display turned off.

I have tried the same thing in live view zoom 5x to test what happen but the frame remain full. (I knew but.. why not try! :P )

May ask I where I can find the patch for avoid the exposure limit?

aprofiti

You can find the exposure limit patch here.

It doesn't works on top of branches with the patch manager (ex crop_rec_4k), but should works good in nightly and lua_fix

Please reports if it's all ok.

Chimico Pazzo

Thank you, (I think to have understood what I must to do)
I will tell something as soon as I try.

Danne

Quote from: a1ex on April 11, 2019, 12:53:35 PM
The full-res silent picture mode can do long exposures (it's limited to 15 seconds in mainline, but there is a patch available for bypassing this limit), so... it's technically possible to implement, as long as you use our DNG format (not CR2).

Just not a priority for me right now.

It's also possible (and maybe easier) to crop the full-res CR2/DNG files in post. I'd try something along these lines:
- extract the Bayer raw data (dcraw -4 -E *.CR2) -> 16-bit PGM files containing unmodified 14-bit raw data
- crop the files with ImageMagick (mogrify -crop 1000x1000+500+500 *.pgm)
- use pgm2dng to convert the PGM files to DNG

Slightly related: the full-res silent picture code can also capture dark frames; it's not implemented either, but if you run it outside LiveView, that's exactly what you are going to get.

Fooling around with this pgm2dng tool I manage to convert back a pgm to dng when using dcraw. This command also works by the way:
dcraw -4 -D
I can also export tiff into pgm with ffmpeg:
ffmpeg -i INPUT.tiff -pix_fmt gray16be OUTPUT.pgm
Now colors are gone so the debayer stuff seems washed away here when transcodeing to dng.

A question. Mogrify crop seems to work as stated in the command above. How about resizing? I tested this:
mogrify -resize x600 INPUT.pgm
And a heavily resized pgm file appears but as soon as converting to dng file color is wrong. Something missing during resize conversion? Is it even possible to do a resize like this and expect something like a lossy dng conversion?

scrax

Quote from: Danne on April 23, 2019, 01:58:53 PM
Now colors are gone so the debayer stuff seems washed away here when transcodeing to dng.

This got my attention, I've tried to get a b/w pic from raw without debayering but managed to get nothing good (see crops)

First is b/w without debayer
then tried to "fix" bayer by a 0.8 gaussian blur
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-

a1ex

Quote from: Danne on April 23, 2019, 01:58:53 PM
dcraw -4 -D

dcraw -4 -E  -> this extracts the complete Bayer raw image data, including optical black areas (undocumented)
dcraw -4 -D  -> extracts only the active area, without optical blacks (otherwise it's the same)

In both cases, the unprocessed Bayer data from the raw file is extracted, without any loss other than metadata, into a PGM. Main reason to do this: you can import this image into octave or other "simple" image processing programs that cannot handle complex formats like CR2 or DNG. In our case, ImageMagick, for cropping. As long as you crop at even offsets (multiples of 2), ImageMagick (mogrify) doesn't need to know the image contains Bayer data - it just copies the pixels without changing their value.

Of course, you can create pgm files with ffmpeg or other programs, but I doubt they will contain raw Bayer data. In this case, conversion to DNG does not make sense. It will work, the container just stores a bunch of numbers, but the image is not going to look as one might expect.

Quotemogrify -resize x600 INPUT.pgm
Resizing a Bayer image at 600%, with a program expecting regular (non-Bayer) image... guess what you are going to get ;)




BTW, png2dng does not play nice with color matrices; it just hardcodes one. You will want to set these with exiftool (copy them from a DNG created with Adobe DNG Converter). It's quite hackish, as I've only used it for experiments, data recovery, sketching image processing algorithms from octave... it wasn't meant to be a end-user tool. Maybe it could be useful.

For this workflow, a "simple" dngcrop utility that would otherwise preserve the metadata would do the trick.

Quote from: scrax on April 23, 2019, 02:40:55 PM
This got my attention, I've tried to get a b/w pic from raw without debayering but managed to get nothing good (see crops)

First is b/w without debayer
then tried to "fix" bayer by a 0.8 gaussian blur

Wait a minute, who gave you "developer" status?!

No offense, just wondering, judging from your recent posts.

Danne

Thanks for answering. Yes, noticed the chdk-dng.h dependency among others and "hackish" ways but it also makes it easy to follow and understand, and to compile.
Back to drawing board....

scrax

No offence at all, since I'm first one who thinks that I'm not a dev, but I have it since the start of the forum I suppose you gave it to me like six. Nearly eight years ago, I was having a 600D at the time and you teached me how to find stuff needed for the port...
In my opinion I don't know C but ML code, since I've started coding in C by following your commits history since then. I wasn't even able to recognize in what language it was written when I first came in contact with ML  :P

Maybe you forgot my preferred topic in 2012 ?
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX, PS, LR, RawTherapee, LightZone -no video experience-