Re: [darktable-dev] How to get image preview zoom factor information

2018-07-11 Thread rawfiner
Again, thank you for all this information!
This does clear up a lot of things :-)

rawfiner

2018-07-11 10:18 GMT+02:00 johannes hanika :

> heya,
>
> On Fri, Jul 6, 2018 at 12:06 AM, rawfiner  wrote:
> > Hi,
> >
> > I am still trying to resize raw before demosaicing to speed up raw
> > denoising.
> >
> > I now get the zoom level using the following code:
> >   float scale = 1.0;
> >   int closeup = dt_control_get_dev_closeup();
> >   if (piece->pipe->type == DT_DEV_PIXELPIPE_FULL)
> > scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0,
> 0);
> >   else if (piece->pipe->type == DT_DEV_PIXELPIPE_PREVIEW)
> > scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0,
> 1);
>
> as of lately, the obscure closeup became more obscure. it should now
> be 1< pixels).
>
> > This works fine in modify_roi_out, but sometimes gives 1 instead of what
> I
> > expect (the zoom factor) when called from modify_roi_in.
> > My problem is to manage to get the scale and use it correctly.
>
> okay. the way the pipeline works is in three stages:
>
> 1) a pass of modify_roi_out() from raw to screen output is performed.
> this is done full resolution, full region of interest, to determine
> the hypothetical size of the output image when processed in full.
>
> 2) given the size and region of interest of the view window, the
> develop module requests a certain input to be able to render the
> output. this is done by calling a chain of modify_roi_in() from view
> window back to raw image. this is only done on the exact pixels that
> are needed on screen right now, i.e. scaled and cropped.
>
> 3) process() is called with about exactly the ROI that were computed
> in pass number 2. i think there are some minor sanity checks done, so
> you shouldn't rely on what you asked for in modify_roi_in but use what
> you get in process().
>
> so in your case i think messing with modify_roi_in() is the more
> important case. you can just request the full image as passed through
> 1) by asking for piece->buf_in or piece->buf_out (these are stored
> when running 1) ).
>
> hope that clears up some things!
>
> cheers,
>  jo
>
> > My module would resize the raw image.
> > Thus, input and output have different dimentions.
> > I tried to set the roi_out width and height with modify_roi_out, this
> works
> > fine.
> >
> > However, even after trying various things in modify_roi_in, I don't
> manage
> > to get the full image as ivoid.
> > First thing that I don't understand is where roi_in is modified between
> > modify_roi_out and modify_roi_in, as at the beginning of modify_roi_in,
> the
> > roi_in width is equal to roi_out width, while they were different at the
> end
> > of roi_out?
> >
> > Also, in modify_roi_out I tried to save the scale in roi_out->scale, but
> in
> > modify_roi_in if I try to print roi_out->scale, I always get 1.
> > Is the roi_out variable used in modify_roi_out different from the one in
> > modify_roi_in?
> >
> > Maybe am I not catching something about the role of these passes.
> >
> > Thanks for any help!
> >
> > Cheers,
> > rawfiner
> >
> > 2018-05-10 23:13 GMT+02:00 rawfiner :
> >>
> >> Thank you for your answer.
> >>
> >> 2018-05-09 13:22 GMT+02:00 johannes hanika :
> >>>
> >>> heya,
> >>>
> >>> On Wed, May 9, 2018 at 12:27 PM, rawfiner  wrote:
> >>> > 2018-05-08 17:16 GMT+02:00 johannes hanika :
> >>> >> i'm guessing you want to detect whether you are running a
> >>> >> DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
> >>> >> DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
> >>> >> yourself before running your algorithm on reduced resolution.
> >>> >>
> >>> >
> >>> > Yes, and I would like to know the zoom factor in case of
> >>> > DT_DEV_PIXELPIPE_PREVIEW , in order to downscale only if the image is
> >>> > sufficiently zoomed out (for example, I don't want to downscale the
> >>> > image if
> >>> > the zoom is at 90%, but I want to downscale if it is below 50%).
> >>>
> >>> right. to determine the total scale factor, you would need to do
> >>> something like for instance in sharpen.c:
> >>>
> >>> const int rad = MIN(MAXR, ceilf(d->radius * roi_in->scale /
> >>> piece->iscale));
> >>>
> >>> which determines the pixel radius scaled by input buffer scaling
> >>> (iscale) and region of interest scaling (roi_in->scale).
> >>
> >>
> >> Yes, I have seen that kind of things in the code of non local means.
> >> Yet, if I understand correctly, this allows to retreive the scale factor
> >> for an already downscaled image, i.e. when the image was downscaled
> >> previously in the pipeline.
> >> What I would like is a bit different, as it would be to know if I can
> >> downscale the image or not, depending on the zoom level in the darkroom.
> >> But I guess that I will find the necessary information in the function
> >> dt_iop_clip_and_zoom_mosaic_half_size_f() that you pointed me out!
> >>
> >>>
> >>> note that the preview pipe is what fills the whole image but
> >>> 

Re: [darktable-dev] How to get image preview zoom factor information

2018-07-11 Thread johannes hanika
heya,

On Fri, Jul 6, 2018 at 12:06 AM, rawfiner  wrote:
> Hi,
>
> I am still trying to resize raw before demosaicing to speed up raw
> denoising.
>
> I now get the zoom level using the following code:
>   float scale = 1.0;
>   int closeup = dt_control_get_dev_closeup();
>   if (piece->pipe->type == DT_DEV_PIXELPIPE_FULL)
> scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0, 0);
>   else if (piece->pipe->type == DT_DEV_PIXELPIPE_PREVIEW)
> scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0, 1);

as of lately, the obscure closeup became more obscure. it should now
be 1< This works fine in modify_roi_out, but sometimes gives 1 instead of what I
> expect (the zoom factor) when called from modify_roi_in.
> My problem is to manage to get the scale and use it correctly.

okay. the way the pipeline works is in three stages:

1) a pass of modify_roi_out() from raw to screen output is performed.
this is done full resolution, full region of interest, to determine
the hypothetical size of the output image when processed in full.

2) given the size and region of interest of the view window, the
develop module requests a certain input to be able to render the
output. this is done by calling a chain of modify_roi_in() from view
window back to raw image. this is only done on the exact pixels that
are needed on screen right now, i.e. scaled and cropped.

3) process() is called with about exactly the ROI that were computed
in pass number 2. i think there are some minor sanity checks done, so
you shouldn't rely on what you asked for in modify_roi_in but use what
you get in process().

so in your case i think messing with modify_roi_in() is the more
important case. you can just request the full image as passed through
1) by asking for piece->buf_in or piece->buf_out (these are stored
when running 1) ).

hope that clears up some things!

cheers,
 jo

> My module would resize the raw image.
> Thus, input and output have different dimentions.
> I tried to set the roi_out width and height with modify_roi_out, this works
> fine.
>
> However, even after trying various things in modify_roi_in, I don't manage
> to get the full image as ivoid.
> First thing that I don't understand is where roi_in is modified between
> modify_roi_out and modify_roi_in, as at the beginning of modify_roi_in, the
> roi_in width is equal to roi_out width, while they were different at the end
> of roi_out?
>
> Also, in modify_roi_out I tried to save the scale in roi_out->scale, but in
> modify_roi_in if I try to print roi_out->scale, I always get 1.
> Is the roi_out variable used in modify_roi_out different from the one in
> modify_roi_in?
>
> Maybe am I not catching something about the role of these passes.
>
> Thanks for any help!
>
> Cheers,
> rawfiner
>
> 2018-05-10 23:13 GMT+02:00 rawfiner :
>>
>> Thank you for your answer.
>>
>> 2018-05-09 13:22 GMT+02:00 johannes hanika :
>>>
>>> heya,
>>>
>>> On Wed, May 9, 2018 at 12:27 PM, rawfiner  wrote:
>>> > 2018-05-08 17:16 GMT+02:00 johannes hanika :
>>> >> i'm guessing you want to detect whether you are running a
>>> >> DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
>>> >> DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
>>> >> yourself before running your algorithm on reduced resolution.
>>> >>
>>> >
>>> > Yes, and I would like to know the zoom factor in case of
>>> > DT_DEV_PIXELPIPE_PREVIEW , in order to downscale only if the image is
>>> > sufficiently zoomed out (for example, I don't want to downscale the
>>> > image if
>>> > the zoom is at 90%, but I want to downscale if it is below 50%).
>>>
>>> right. to determine the total scale factor, you would need to do
>>> something like for instance in sharpen.c:
>>>
>>> const int rad = MIN(MAXR, ceilf(d->radius * roi_in->scale /
>>> piece->iscale));
>>>
>>> which determines the pixel radius scaled by input buffer scaling
>>> (iscale) and region of interest scaling (roi_in->scale).
>>
>>
>> Yes, I have seen that kind of things in the code of non local means.
>> Yet, if I understand correctly, this allows to retreive the scale factor
>> for an already downscaled image, i.e. when the image was downscaled
>> previously in the pipeline.
>> What I would like is a bit different, as it would be to know if I can
>> downscale the image or not, depending on the zoom level in the darkroom.
>> But I guess that I will find the necessary information in the function
>> dt_iop_clip_and_zoom_mosaic_half_size_f() that you pointed me out!
>>
>>>
>>> note that the preview pipe is what fills the whole image but
>>> downscaled (iscale != 1) in the navigation view in the top left
>>> corner. the "full" pipeline fills the pixels in the center view of
>>> darkroom mode, at exactly the scale and crop you see on screen (iscale
>>> == 1 mostly but the other scale and bounds in roi_in will change with
>>> the current view).
>>>
>>> to find out whether you're running either one of the two you'd write
>>> something 

Re: [darktable-dev] How to get image preview zoom factor information

2018-07-11 Thread johannes hanika
hi,

let me try to fill in some gaps:

On Tue, Jul 10, 2018 at 8:32 AM, rawfiner  wrote:
> Dear all,
>
> I think that I do not manage to differenciate correctly the role of some
> variables.
> What is the difference between:
> -roi_out->scale

that is the current output region of interest scale, relating what
would happen when you had processed the full resolution image vs. what
is actually being processed in the pipe now. sorry i forget which way
around scale = a/b or = b/a it is.

> -piece->iscale

this is the input scale factor, i.e. how much did the pipeline where
the current piece belongs to downsize the real input (raw image)
before throwing it into the pipeline. this should be 1.0 for the full
and export pipelines and may be different for the preview. again i
forgot whether this should be < or > 1 in that case.

> -self->dev->preview_pipe->iscale

if the piece is a piece of the preview pipeline, these last two should
be the same (the piece copies iscale and iwidth/iheight for
convenience. also there were places at least in the past where you
would have the piece but not the whole pipe)

> And the difference between:
> -roi_out->width

the size of the output buffer that is passed to process() for
instance. note that these may be different for each module, because
some require some padding or need to run on full res bayer data, do
distortions etc.

> -piece->iwidth

see above. width of the prescaled input. should be == raw resolution
unless you're running a preview pipeline.


> -self->dev->preview_pipe->processed_width

that's the output size of the fully processed image, i.e. what would
be stored on disk if you were running an export pipeline. this is
needed up front to get scale to fit work correctly for instance. it's
computed by a chain of modify_roi_out() which is run in a first pass
with the full input buffer resolution and full region of interest.

> -self->dev->width

that is the size of the develop view. i.e. if you need to determine
the scale factor for the pipeline, you would relate this view window
size to the processed_width above, and then run the pipeline.


> Which variable has to be used for which purpose?
>
> What I currently have:
> before downscaling:
> https://drive.google.com/open?id=12Zj_Pcyhnm1yt_kgSS6F01q979TLMVMO
> after downscaling, we are too zoomed out:
> https://drive.google.com/open?id=1eMQ-wj8DznKT7GNoZy7pRtOvkUB-_vk1
> I would like to "tell the engine" that we are downscaling the image for the
> preview, and that the 29% zoom is going to become a 100% zoom (as the image
> is smaller), but without affecting the information visible by the user (the
> user will see that he is at 29% zoom).
> Basically, the user should see no difference whether the downscaling is
> activated or not

you want to downscale more than the pipeline usually does? i think at
the zoom-to-fit scale usually we'd downscale the input very early,
unless one module requests full raw data at full resolution. i'm
assuming your module comes before demosaic with requests the roi_in of
full resolution (see the line roi_in->scale = 1.0f; in modify_roi_in()
in src/iop/demosaic.c). as much as i hate inter-module dependencies
you may need to mess with that to achieve what you need.

the alternative is to implement your own modify_roi_in() that undoes
these changes and requests a much smaller input scale. in this case i
think you should leave modify_roi_out as passthrough, because that is
only called on full res full roi and computes the output size given
the full input (to ultimately compute processed_width).

hope that helps.

cheers,
 jo

>
> Thank you for any help
>
> rawfiner
>
>
>
> 2018-07-06 0:06 GMT+02:00 rawfiner :
>>
>> Hi,
>>
>> I am still trying to resize raw before demosaicing to speed up raw
>> denoising.
>>
>> I now get the zoom level using the following code:
>>   float scale = 1.0;
>>   int closeup = dt_control_get_dev_closeup();
>>   if (piece->pipe->type == DT_DEV_PIXELPIPE_FULL)
>> scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0,
>> 0);
>>   else if (piece->pipe->type == DT_DEV_PIXELPIPE_PREVIEW)
>> scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0,
>> 1);
>>
>> This works fine in modify_roi_out, but sometimes gives 1 instead of what I
>> expect (the zoom factor) when called from modify_roi_in.
>> My problem is to manage to get the scale and use it correctly.
>>
>> My module would resize the raw image.
>> Thus, input and output have different dimentions.
>> I tried to set the roi_out width and height with modify_roi_out, this
>> works fine.
>>
>> However, even after trying various things in modify_roi_in, I don't manage
>> to get the full image as ivoid.
>> First thing that I don't understand is where roi_in is modified between
>> modify_roi_out and modify_roi_in, as at the beginning of modify_roi_in, the
>> roi_in width is equal to roi_out width, while they were different at the end
>> of roi_out?
>>
>> Also, in modify_roi_out I tried to save the 

Re: [darktable-dev] How to get image preview zoom factor information

2018-07-10 Thread rawfiner
Dear all,

I think that I do not manage to differenciate correctly the role of some
variables.
What is the difference between:
-roi_out->scale
-piece->iscale
-self->dev->preview_pipe->iscale

And the difference between:
-roi_out->width
-piece->iwidth
-self->dev->preview_pipe->processed_width
-self->dev->width

Which variable has to be used for which purpose?

What I currently have:
before downscaling:
https://drive.google.com/open?id=12Zj_Pcyhnm1yt_kgSS6F01q979TLMVMO
after downscaling, we are too zoomed out:
https://drive.google.com/open?id=1eMQ-wj8DznKT7GNoZy7pRtOvkUB-_vk1
I would like to "tell the engine" that we are downscaling the image for the
preview, and that the 29% zoom is going to become a 100% zoom (as the image
is smaller), but without affecting the information visible by the user (the
user will see that he is at 29% zoom).
Basically, the user should see no difference whether the downscaling is
activated or not

Thank you for any help

rawfiner



2018-07-06 0:06 GMT+02:00 rawfiner :

> Hi,
>
> I am still trying to resize raw before demosaicing to speed up raw
> denoising.
>
> I now get the zoom level using the following code:
>   float scale = 1.0;
>   int closeup = dt_control_get_dev_closeup();
>   if (piece->pipe->type == DT_DEV_PIXELPIPE_FULL)
> scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0,
> 0);
>   else if (piece->pipe->type == DT_DEV_PIXELPIPE_PREVIEW)
> scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0,
> 1);
>
> This works fine in modify_roi_out, but sometimes gives 1 instead of what I
> expect (the zoom factor) when called from modify_roi_in.
> My problem is to manage to get the scale and use it correctly.
>
> My module would resize the raw image.
> Thus, input and output have different dimentions.
> I tried to set the roi_out width and height with modify_roi_out, this
> works fine.
>
> However, even after trying various things in modify_roi_in, I don't manage
> to get the full image as ivoid.
> First thing that I don't understand is where roi_in is modified between
> modify_roi_out and modify_roi_in, as at the beginning of modify_roi_in, the
> roi_in width is equal to roi_out width, while they were different at the
> end of roi_out?
>
> Also, in modify_roi_out I tried to save the scale in roi_out->scale, but
> in modify_roi_in if I try to print roi_out->scale, I always get 1.
> Is the roi_out variable used in modify_roi_out different from the one in
> modify_roi_in?
>
> Maybe am I not catching something about the role of these passes.
>
> Thanks for any help!
>
> Cheers,
> rawfiner
>
> 2018-05-10 23:13 GMT+02:00 rawfiner :
>
>> Thank you for your answer.
>>
>> 2018-05-09 13:22 GMT+02:00 johannes hanika :
>>
>>> heya,
>>>
>>> On Wed, May 9, 2018 at 12:27 PM, rawfiner  wrote:
>>> > 2018-05-08 17:16 GMT+02:00 johannes hanika :
>>> >> i'm guessing you want to detect whether you are running a
>>> >> DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
>>> >> DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
>>> >> yourself before running your algorithm on reduced resolution.
>>> >>
>>> >
>>> > Yes, and I would like to know the zoom factor in case of
>>> > DT_DEV_PIXELPIPE_PREVIEW , in order to downscale only if the image is
>>> > sufficiently zoomed out (for example, I don't want to downscale the
>>> image if
>>> > the zoom is at 90%, but I want to downscale if it is below 50%).
>>>
>>> right. to determine the total scale factor, you would need to do
>>> something like for instance in sharpen.c:
>>>
>>> const int rad = MIN(MAXR, ceilf(d->radius * roi_in->scale /
>>> piece->iscale));
>>>
>>> which determines the pixel radius scaled by input buffer scaling
>>> (iscale) and region of interest scaling (roi_in->scale).
>>>
>>
>> Yes, I have seen that kind of things in the code of non local means.
>> Yet, if I understand correctly, this allows to retreive the scale factor
>> for an already downscaled image, i.e. when the image was downscaled
>> previously in the pipeline.
>> What I would like is a bit different, as it would be to know if I can
>> downscale the image or not, depending on the zoom level in the darkroom.
>> But I guess that I will find the necessary information in the function
>> dt_iop_clip_and_zoom_mosaic_half_size_f() that you pointed me out!
>>
>>
>>> note that the preview pipe is what fills the whole image but
>>> downscaled (iscale != 1) in the navigation view in the top left
>>> corner. the "full" pipeline fills the pixels in the center view of
>>> darkroom mode, at exactly the scale and crop you see on screen (iscale
>>> == 1 mostly but the other scale and bounds in roi_in will change with
>>> the current view).
>>>
>>> to find out whether you're running either one of the two you'd write
>>> something similar to bilat.c:
>>>
>>> if(self->dev->gui_attached && g && piece->pipe->type ==
>>> DT_DEV_PIXELPIPE_PREVIEW)
>>>
>>
>> Ok, thank you for these explainations
>> I think I have everything I need to make 

Re: [darktable-dev] How to get image preview zoom factor information

2018-07-05 Thread rawfiner
Hi,

I am still trying to resize raw before demosaicing to speed up raw
denoising.

I now get the zoom level using the following code:
  float scale = 1.0;
  int closeup = dt_control_get_dev_closeup();
  if (piece->pipe->type == DT_DEV_PIXELPIPE_FULL)
scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0, 0);
  else if (piece->pipe->type == DT_DEV_PIXELPIPE_PREVIEW)
scale = dt_dev_get_zoom_scale(self->dev, zoom, closeup ? 2.0 : 1.0, 1);

This works fine in modify_roi_out, but sometimes gives 1 instead of what I
expect (the zoom factor) when called from modify_roi_in.
My problem is to manage to get the scale and use it correctly.

My module would resize the raw image.
Thus, input and output have different dimentions.
I tried to set the roi_out width and height with modify_roi_out, this works
fine.

However, even after trying various things in modify_roi_in, I don't manage
to get the full image as ivoid.
First thing that I don't understand is where roi_in is modified between
modify_roi_out and modify_roi_in, as at the beginning of modify_roi_in, the
roi_in width is equal to roi_out width, while they were different at the
end of roi_out?

Also, in modify_roi_out I tried to save the scale in roi_out->scale, but in
modify_roi_in if I try to print roi_out->scale, I always get 1.
Is the roi_out variable used in modify_roi_out different from the one in
modify_roi_in?

Maybe am I not catching something about the role of these passes.

Thanks for any help!

Cheers,
rawfiner

2018-05-10 23:13 GMT+02:00 rawfiner :

> Thank you for your answer.
>
> 2018-05-09 13:22 GMT+02:00 johannes hanika :
>
>> heya,
>>
>> On Wed, May 9, 2018 at 12:27 PM, rawfiner  wrote:
>> > 2018-05-08 17:16 GMT+02:00 johannes hanika :
>> >> i'm guessing you want to detect whether you are running a
>> >> DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
>> >> DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
>> >> yourself before running your algorithm on reduced resolution.
>> >>
>> >
>> > Yes, and I would like to know the zoom factor in case of
>> > DT_DEV_PIXELPIPE_PREVIEW , in order to downscale only if the image is
>> > sufficiently zoomed out (for example, I don't want to downscale the
>> image if
>> > the zoom is at 90%, but I want to downscale if it is below 50%).
>>
>> right. to determine the total scale factor, you would need to do
>> something like for instance in sharpen.c:
>>
>> const int rad = MIN(MAXR, ceilf(d->radius * roi_in->scale /
>> piece->iscale));
>>
>> which determines the pixel radius scaled by input buffer scaling
>> (iscale) and region of interest scaling (roi_in->scale).
>>
>
> Yes, I have seen that kind of things in the code of non local means.
> Yet, if I understand correctly, this allows to retreive the scale factor
> for an already downscaled image, i.e. when the image was downscaled
> previously in the pipeline.
> What I would like is a bit different, as it would be to know if I can
> downscale the image or not, depending on the zoom level in the darkroom.
> But I guess that I will find the necessary information in the function
> dt_iop_clip_and_zoom_mosaic_half_size_f() that you pointed me out!
>
>
>> note that the preview pipe is what fills the whole image but
>> downscaled (iscale != 1) in the navigation view in the top left
>> corner. the "full" pipeline fills the pixels in the center view of
>> darkroom mode, at exactly the scale and crop you see on screen (iscale
>> == 1 mostly but the other scale and bounds in roi_in will change with
>> the current view).
>>
>> to find out whether you're running either one of the two you'd write
>> something similar to bilat.c:
>>
>> if(self->dev->gui_attached && g && piece->pipe->type ==
>> DT_DEV_PIXELPIPE_PREVIEW)
>>
>
> Ok, thank you for these explainations
> I think I have everything I need to make some new trials!
>
> Regards,
>
> rawfiner
>
>

___
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org

Re: [darktable-dev] How to get image preview zoom factor information

2018-05-10 Thread rawfiner
Thank you for your answer.

2018-05-09 13:22 GMT+02:00 johannes hanika :

> heya,
>
> On Wed, May 9, 2018 at 12:27 PM, rawfiner  wrote:
> > 2018-05-08 17:16 GMT+02:00 johannes hanika :
> >> i'm guessing you want to detect whether you are running a
> >> DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
> >> DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
> >> yourself before running your algorithm on reduced resolution.
> >>
> >
> > Yes, and I would like to know the zoom factor in case of
> > DT_DEV_PIXELPIPE_PREVIEW , in order to downscale only if the image is
> > sufficiently zoomed out (for example, I don't want to downscale the
> image if
> > the zoom is at 90%, but I want to downscale if it is below 50%).
>
> right. to determine the total scale factor, you would need to do
> something like for instance in sharpen.c:
>
> const int rad = MIN(MAXR, ceilf(d->radius * roi_in->scale /
> piece->iscale));
>
> which determines the pixel radius scaled by input buffer scaling
> (iscale) and region of interest scaling (roi_in->scale).
>

Yes, I have seen that kind of things in the code of non local means.
Yet, if I understand correctly, this allows to retreive the scale factor
for an already downscaled image, i.e. when the image was downscaled
previously in the pipeline.
What I would like is a bit different, as it would be to know if I can
downscale the image or not, depending on the zoom level in the darkroom.
But I guess that I will find the necessary information in the function
dt_iop_clip_and_zoom_mosaic_half_size_f() that you pointed me out!


> note that the preview pipe is what fills the whole image but
> downscaled (iscale != 1) in the navigation view in the top left
> corner. the "full" pipeline fills the pixels in the center view of
> darkroom mode, at exactly the scale and crop you see on screen (iscale
> == 1 mostly but the other scale and bounds in roi_in will change with
> the current view).
>
> to find out whether you're running either one of the two you'd write
> something similar to bilat.c:
>
> if(self->dev->gui_attached && g && piece->pipe->type ==
> DT_DEV_PIXELPIPE_PREVIEW)
>

Ok, thank you for these explainations
I think I have everything I need to make some new trials!

Regards,

rawfiner

___
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org

Re: [darktable-dev] How to get image preview zoom factor information

2018-05-09 Thread johannes hanika
heya,

On Wed, May 9, 2018 at 12:27 PM, rawfiner  wrote:
> 2018-05-08 17:16 GMT+02:00 johannes hanika :
>> i'm guessing you want to detect whether you are running a
>> DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
>> DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
>> yourself before running your algorithm on reduced resolution.
>>
>
> Yes, and I would like to know the zoom factor in case of
> DT_DEV_PIXELPIPE_PREVIEW , in order to downscale only if the image is
> sufficiently zoomed out (for example, I don't want to downscale the image if
> the zoom is at 90%, but I want to downscale if it is below 50%).

right. to determine the total scale factor, you would need to do
something like for instance in sharpen.c:

const int rad = MIN(MAXR, ceilf(d->radius * roi_in->scale / piece->iscale));

which determines the pixel radius scaled by input buffer scaling
(iscale) and region of interest scaling (roi_in->scale).

note that the preview pipe is what fills the whole image but
downscaled (iscale != 1) in the navigation view in the top left
corner. the "full" pipeline fills the pixels in the center view of
darkroom mode, at exactly the scale and crop you see on screen (iscale
== 1 mostly but the other scale and bounds in roi_in will change with
the current view).

to find out whether you're running either one of the two you'd write
something similar to bilat.c:

if(self->dev->gui_attached && g && piece->pipe->type ==
DT_DEV_PIXELPIPE_PREVIEW)

cheers,
 jo
___
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org



Re: [darktable-dev] How to get image preview zoom factor information

2018-05-09 Thread rawfiner
Thank you for the detailed answer

2018-05-08 17:16 GMT+02:00 johannes hanika :

> heya,
>
> for modules that work on raw data, the full pipeline is unscaled
> (hence your constant scale factors). all we do here is provide input
> cropped to the region of interest your module requested during the
> modify_roi_in() pass that is run before process() is called (there is
> a default implementation of modify_roi_in).
>

> we have some experimental/working code that downsizes raw data so that
> the preview pipeline can be run on raw/mosaic input, yet downscaled
> buffers. look for functions like
> dt_iop_clip_and_zoom_mosaic_half_size_f().
>

Cool, I will look at this!


>
> i'm guessing you want to detect whether you are running a
> DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
> DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
> yourself before running your algorithm on reduced resolution.
>
>
Yes, and I would like to know the zoom factor in case of
DT_DEV_PIXELPIPE_PREVIEW , in order to downscale only if the image is
sufficiently zoomed out (for example, I don't want to downscale the image
if the zoom is at 90%, but I want to downscale if it is below 50%).


> note that there are some problems with this when it comes to aliasing
> or the treatment of filtered colours, some of which may be above the
> raw clipping threshold.
>

I can imagine that downscaling raw is far from easy. I think (hope?) that,
maybe, the denoising step *may* reduce the artifacts that result of the
downscaling. Anyway, I will have to test this to figure out if it is an
acceptable solution or not!


>
> let me know how you go with this, sounds very interesting!
> cheers,
>  jo
>

Ok I'll do that!
Thank you again for your help.

rawfiner


>
> On Tue, May 8, 2018 at 8:28 AM, rawfiner  wrote:
> > Dear all,
> >
> > I am currently working on a module for denoising at raw level.
> > The first results are very promising in term of denoising quality, but
> the
> > speed of the module is not as fast as it should be (processing the full
> > image takes about 20 seconds, which is decent for export but too slow for
> > the processing in darkroom).
> >
> > The denoising modules that work on the image after demosaic can display
> > previews in darkroom fastly as they work on a downscaled version of the
> > image.
> >
> > I would like to investigate if simple methods of downscaling could work
> > decently at raw level, so that raw denoising could compute a fast
> preview on
> > the downscaled image.
> >
> > My question is, how (if it is possible) can I get the zoom factor of the
> > darkroom within the raw denoise module ?
> > I tried to look into the data available in "piece", but did not find
> > anything that could give me the zoom factor.
> > (piece->iscale is constantly equal to 1, no matter the zoom level, and
> the
> > same holds for piece->buf_in.scale)
> >
> > Thank you !
> >
> > Regards,
> >
> > rawfiner
> >
> > 
> ___
> > darktable developer mailing list to unsubscribe send a mail to
> > darktable-dev+unsubscr...@lists.darktable.org
>

___
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org

Re: [darktable-dev] How to get image preview zoom factor information

2018-05-08 Thread johannes hanika
heya,

for modules that work on raw data, the full pipeline is unscaled
(hence your constant scale factors). all we do here is provide input
cropped to the region of interest your module requested during the
modify_roi_in() pass that is run before process() is called (there is
a default implementation of modify_roi_in).

we have some experimental/working code that downsizes raw data so that
the preview pipeline can be run on raw/mosaic input, yet downscaled
buffers. look for functions like
dt_iop_clip_and_zoom_mosaic_half_size_f().

i'm guessing you want to detect whether you are running a
DT_DEV_PIXELPIPE_FULL pipe in darkroom mode (as opposed to
DT_DEV_PIXELPIPE_PREVIEW or _EXPORT) and then do this downscaling
yourself before running your algorithm on reduced resolution.

note that there are some problems with this when it comes to aliasing
or the treatment of filtered colours, some of which may be above the
raw clipping threshold.

let me know how you go with this, sounds very interesting!
cheers,
 jo

On Tue, May 8, 2018 at 8:28 AM, rawfiner  wrote:
> Dear all,
>
> I am currently working on a module for denoising at raw level.
> The first results are very promising in term of denoising quality, but the
> speed of the module is not as fast as it should be (processing the full
> image takes about 20 seconds, which is decent for export but too slow for
> the processing in darkroom).
>
> The denoising modules that work on the image after demosaic can display
> previews in darkroom fastly as they work on a downscaled version of the
> image.
>
> I would like to investigate if simple methods of downscaling could work
> decently at raw level, so that raw denoising could compute a fast preview on
> the downscaled image.
>
> My question is, how (if it is possible) can I get the zoom factor of the
> darkroom within the raw denoise module ?
> I tried to look into the data available in "piece", but did not find
> anything that could give me the zoom factor.
> (piece->iscale is constantly equal to 1, no matter the zoom level, and the
> same holds for piece->buf_in.scale)
>
> Thank you !
>
> Regards,
>
> rawfiner
>
> ___
> darktable developer mailing list to unsubscribe send a mail to
> darktable-dev+unsubscr...@lists.darktable.org
___
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org