Skip to content

color picker updates: restrict histogram fix, overlay drawing change, internal fixes#9835

Merged
TurboGit merged 58 commits intodarktable-org:masterfrom
dtorop:restrict-histogram-during-edit
Aug 27, 2021
Merged

color picker updates: restrict histogram fix, overlay drawing change, internal fixes#9835
TurboGit merged 58 commits intodarktable-org:masterfrom
dtorop:restrict-histogram-during-edit

Conversation

@dtorop
Copy link
Contributor

@dtorop dtorop commented Aug 19, 2021

This is a mix of

  • a functional change: allowing colorpickers to "defocus" without disappearing, which lets "restrict histogram to selection" work when tuning iops
  • visual work on colorpicker display in the center view
  • trying to straighten out and clean up the underlying code
  • misc. other changes (see below)

Change behavior of color pickers

  • When the "primary" color picker is on (via the left panel), then the user enables an iop, the primary colorpicker no longer disappears, but is merely drawn dimmer and with drag handles removed. It continues to sample the image and produce data on the left panel. If "restrict histogram to selection" is enabled, it will continue to restrict the histogram. This allows for tuning iops with the benefit of "restrict histogram" and fixes color picker: restrict histogram to selection #5689.
  • When an module's color picker is used and "restrict histogram to selection" is enabled, the histogram is restricted based on the area of the iop's color picker.
  • The color picker drawing code is slightly different. Rather than drawing a light and dark outline slightly offset, it draws a light outline with a dark border. There is a slight gap in the center of the "crosshair" of the point colorpicker, to make sure that the sampled point is visible. Scaling of the picker point as shown in the center view is slightly different as well (it will never get too large or too small).
  • The live sample pickers are drawn quite differently. Rather than being drawn with a blue border, they are drawn as crosshair (for points) or dotted rectangle (for boxes). If they are "selected" via mouseover, they are drawn larger and/or with thicker borders for emphasis. The rationale is that blue/red outlines confuse the color understanding of an image.
  • The detection of mouse-down on box colorpicker drag handles was incorrect, particularly for images with unusual aspect ratios. It should now be fairly pixel-accurate.
  • When switching between point/box modes for a module's picker, the prior mode's picker position is not lost.

Internal changes

  • Code to sample "primary" and live sample pickers is unified. This reduces lines of code, and means that a bunch of LittleCMS setup doesn't need to be run twice.
  • Code to draw primary and live sample picker overlays is unified. Subtle differences between the two sorts of overlays are removed.
  • Previously each iop stored its own active box/point picker location. Instead, this is now stored "globally" in the primary colorpicker. The color picker "proxy" objects still also store the most recent box/point locations for each colorpicker.
  • There was code to configure per-iop the initial location/size of point/box pickers. But this code didn't actual alter these positions, and is now removed.
  • Code to "set_sample_area" which was unused is removed.
  • The actual sampling code in the pixelpipe should be slightly optimized.

Caveats/worries

  • This is a lot of changes. Some cleanups, some changes in behaviors, some visual changes. There is a lot which can go wrong here, and I've probably missed quite a few cases. It seemed better to put up this PR now that it is usable, rather than hold out and see if I can find the remaining bugs.
  • The existing code is, as far as I can tell, stable and reliable. It seems important not to make this a step back.
  • There may need to be a layer of proxy/mutex code between the UI and the data structures to prevent weird behavior. I haven't done this, and don't know if this PR will make some things unstable.
  • There are still some other cleanups possible. One example is that I think that per-module colorpickers do a colorspace transform for the entire buffer even if there is simply a single point being sampled.
  • I worry about the visibility of the colorpicker overlays in the center view. This could be adjusted.
  • There are probably some more changes besides those listed above.

Examples of visual changes

Screenshots are at 200% due to being from a hidpi display. Image is a cloudy sky, to demonstrate an image in which it is somewhat difficult to see the picker overlay

Point colorpicker

Focused

image

Defocused

image

Live sample

image

"Selected" live sample

image

Box colorpicker

Focused

image

Defocused

image

Live sample

image

"Selected" live sample

image

@Mark-64
Copy link
Contributor

Mark-64 commented Aug 19, 2021

Awesome work!
I am testing it, some feedback below (and feel free to disregard if not easy to implement)

  1. I like the new design of the point sample with the central pixel visible, but on a HiDPI screen single pixels can't be seen. What about showing inside the box a magnified version of the image (to 100% or 200%) so one can actually see the point being sampled?
  2. Suppose you sample a point or an area, you go to interact with a module, then you click back on the global picker => selection will restart from scratch (from center of image for the point picker or whole image for the area picker). Maybe it would be handier to restart from the old selection?
  3. About visibility of the picker, why not highlight on mouse over like it is done for the live samples?

I will do more test on the module pickers

@johnny-bit johnny-bit added bugfix pull request fixing a bug feature: enhancement current features to improve scope: UI user interface and interactions labels Aug 19, 2021
@dterrahe
Copy link
Contributor

First off, many thanks for picking this up and let me congratulate you on your bravery! When I looked at this, the complexity of untangling the many layers daunted me and I stopped at the proxy layer.

I've only had a quick look, but the pickers themselves look so much better and thanks for fixing the handle dragging under zoom that I never got round to. Maybe the point picker shouldn't scale with zoom though?

Of course this will need a lot of testing as there are many subtleties. There used to be issues with modules either receiving updates too often, or not receiving an initial update at all immediately after a picker was switched on. This was the reason for initialising with NaN for each state switch, to force an update even if the previous and current picker had same (default) selection. Even to test for this is finicky...

People are very sensitive to small changes in behaviour, even if they are "objectively" improvements. Don your thick skin!

@johnny-bit johnny-bit added difficulty: hard big changes across different parts of the code base documentation-pending a documentation work is required feature: redesign current features to rewrite scope: codebase making darktable source code easier to manage labels Aug 19, 2021
@Mark-64
Copy link
Contributor

Mark-64 commented Aug 19, 2021

I found one issue, with this PR the overlay gradient line in module graduated density is no longer visible.
EDIT: same with the special cursor in tone equalizer and drawn mask in all modules, I guess it interferes with other overlays

@dtorop
Copy link
Contributor Author

dtorop commented Aug 19, 2021

@dterrahe @Mark-64 Thank you for notes/tests. I'm grateful for the eyes on this now, even if it means putting up a PR that isn't yet ironclad.

Maybe the point picker shouldn't scale with zoom

I've wondered about this as well. It would make the draw code much simpler. Having it scale with zoom gives a visual cue that the zoom level has changed. (Box pickers give that cue by increasing/decreasing the box size with zoom.) But to really give this cue, the line width of the scope should also increase, at least when > 1:1 pixel resolution.

I like the new design of the point sample with the central pixel visible, but on a HiDPI screen single pixels can't be seen.

And this is yet harder due to the zoomable point picker. Another problem: When the center view is zoomed in, the pixel in the center of the crosshair doesn't actually represent the output sample. This is because the picker is reading the (low-res) preview pipe, and is missing a bunch of extra detail in the region-of-interest. I'll take another look at this.

What about showing inside the box a magnified version of the image (to 100% or 200%) so one can actually see the point being sampled?

Interesting idea. I'll see if it's viable -- whether it works with (or against) what Cairo makes easy. And how to present this nicely.

As above, we have to be careful as what appears to be in the center of the picker in the center view may not actually be what the picker is using for its sample.

About visibility of the picker, why not highlight on mouse over like it is done for the live samples

This is a good idea. Are you thinking to highlight it when mouse over the primary picker readout in the left panel (as with live samples)? That should be pretty easy to do. Highlighting it when mouse-over in center view may be possible, but would be harder. If so, it could also highlight live samples on mouse over as well.

Suppose you sample a point or an area, you go to interact with a module, then you click back on the global picker => selection will restart from scratch (from center of image for the point picker or whole image for the area picker). Maybe it would be handier to restart from the old selection?

I've been wondering about this too. I think the current code makes it hard to restore the picker location for the primary picker, but it should be possible to do a workaround.

Another question is if we have an iop picker turned on, then turn click on the primary picker, what should happen when the primary picker activates:

  1. Reset the primary picker area (current behavior)
  2. Recall the last primary picker area (as above when there is no iop picker on)
  3. Use the currently on iop picker's location -- though what if we switch from a point picker in an iop to a box picker in the primary picker, do we go back to 1) or 2)?

I'm thinking 2) is the best option, and the most straightforward (no special cases).

the overlay gradient line in module graduated density is no longer visible.
same with the special cursor in tone equalizer and drawn mask in all modules, I guess it interferes with other overlays

Thank you for catching. I'll work on this.

I stopped at the proxy layer

I spent a long time not understanding the proxy layer. But this PR should actually increase its importance -- it's very much a key hub which connects and sets behaviors for the picker widgets, the center view, and the actual picking code.

Of course this will need a lot of testing as there are many subtleties.

Yes!

This was the reason for initialising with NaN for each state switch, to force an update even if the previous and current picker had same (default) selection. Even to test for this is finicky...

Makes sense. I'll look at this carefully.

Don your thick skin!

Will do!

@TurboGit
Copy link
Member

I spent a long time not understanding the proxy layer. But this PR should actually increase its importance -- it's very much a key hub which connects and sets behaviors for the picker widgets, the center view, and the actual picking code.

By all mean do not hesitate to put as much comment in the code to help others grasping this part. TIA.

@dterrahe
Copy link
Contributor

Having it scale with zoom gives a visual cue that the zoom level has changed. (Box pickers give that cue by increasing/decreasing the box size with zoom.)

I'm not sure that visual clue is needed; it is not provided when there is no picker active. The box size increasing is just, well, because it is more zoomed in. I find the large point picker strange/ungainly. But that's only one opinion of course!

what appears to be in the center of the picker in the center view may not actually be what the picker is using for its sample.

It might be nice to show the color that is actually picked in the center of the picker. That is, create a dot of a few pixels that is filled with the picker result. But maybe that has not been calculated yet when the picker shape is drawn, so this might be hard?

I'm thinking 2) is the best option, and the most straightforward (no special cases).

Makes the most sense to me too.

Two quick ideas:

  • allow adding live samples while any picker is active, instead of just the primary. The result will be different, because it is evaluated at a different stage in the pipe, but this way one can save an area
  • set the currently active picker area/spot to a live sample (by clicking on it in the list)

One could combined those two to allow passing any picker to another one.

@Mark-64
Copy link
Contributor

Mark-64 commented Aug 19, 2021

Are you thinking to highlight it when mouse over the primary picker readout in the left panel (as with live samples)? That should be pretty easy to do

Yes, let's keep things simple

@dtorop
Copy link
Contributor Author

dtorop commented Aug 20, 2021

It might be nice to show the color that is actually picked in the center of the picker. That is, create a dot of a few pixels that is filled with the picker result. But maybe that has not been calculated yet when the picker shape is drawn, so this might be hard?

This should be available by the time the center view is redrawn. I'll see!

Another thought is to make the central square the size of a pixel in the preview pipe, to give a since of the sample resolution. When zoomed out sufficiently, this would have a minimum size (4x4 pixel square?). This would keep some vestige of a visual cue to zoom level, but more importantly would let the user know that the point sample isn't actual sampling pixels 1:1 from the full pixelpipe but rather from preview pixelpipe.

Maybe the picker is a crosshairs, with sample-colored square in the middle, and when it is focused/moveable there's a square (or circle, if not looking too much like a rifle sight?) around it.

  • allow adding live samples while any picker is active, instead of just the primary. The result will be different, because it is evaluated at a different stage in the pipe, but this way one can save an area

Yes! The live sample would be sampling the end of the pixelpipe (as always), yes? Not a special case where it sampled at the iop (harder to do & confusing).

  • set the currently active picker area/spot to a live sample (by clicking on it in the list)

Yes! Clicking on the swatch currently "locks" the live sample (a bit of an obscure feature...), but at the least clicking on the readout numbers could copy the sample area.

Lots to do, but these all seem good changes to add in to this PR.

@dtorop
Copy link
Contributor Author

dtorop commented Aug 20, 2021

Another minor thing: Especially when dragging the point sample, the mouse pointer's "arrow" cursor gets in the way of seeing what's happening. It would be nice to hide the GDK cursor then, but there'd need to be some additional visual clue that the colorpicker is being dragged...

@MStraeten
Copy link
Collaborator

great work, here my findings on a first view:
unfortunately moving the live-picker results in a reprocessing of the preview image each time the picker is set, so it comes with a price - depending on the used hardware and the pixelpipe this can be very time consuming (a 'working...' on picking a color for setting a parametric mask is annoying)

while in vectorscope displaying the picked color is fine (just the white spot) restricting the histogram when using the picker in a processing module (right panel) is strange and not useful in my opinion. If i select the restriction in the left panel it's about evaluating the selected area/point in the histogram; in color picker mode in the right panel it’s about getting color info to set a parametric mask, a controlpoint,... not to evaluate the histogram.

@dterrahe
Copy link
Contributor

the picker is a crosshairs, with sample-colored square in the middle

I like it!

The live sample would be sampling the end of the pixelpipe (as always), yes?

Yes, definitely. Maybe there are educational opportunities here to teach newcomers about sampling colorpickers at different stages of the pipe, but I have no ideas on how to approach that. They may just have to RTFM.

Clicking on the swatch currently "locks" the live sample (a bit of an obscure feature...), but at the least clicking on the readout numbers could copy the sample area.

That would be a very subtle difference depending on area. Maybe a right-click on swatch instead? Clicking on the numbers might be better used to implement #9836.

Btw I assume you have on your todo that hovering over live point sample still shows zoomed cross (your pace of change is impressive).

Other idea (complementary to above); currently right clicking in center view always resets area to full image. What about if you right click within a live sample, it sets current picker to same area as sample? And if overlapping samples, multiple right-clicks cycle between them. And one of the stops in the cycle is full image, so still incorporates current functionality. Right-click in center and right-click on swatch would be consistent/"intuitive".

@johnny-bit
Copy link
Member

Maybe there are educational opportunities here to teach newcomers about sampling colorpickers at different stages of the pipe,

Jiyone on IRC asked if it would be possible to sample color very early in the pipe, probably at raw black/white point or demosaic, mainly for callibrating film scans done with camera where red channel of base film needs to be in 90-100% range

@Mark-64 Mark-64 mentioned this pull request Aug 21, 2021
@TurboGit TurboGit added this to the 3.8 milestone Aug 21, 2021
@dtorop
Copy link
Contributor Author

dtorop commented Aug 22, 2021

unfortunately moving the live-picker results in a reprocessing of the preview image each time the picker is set

Yes, I see this as well. It's particularly annoying at 400%. I thought this was just how the code worked, but sounds like it's something I broke. I'll look at it.

If i select the restriction in the left panel it's about evaluating the selected area/point in the histogram; in color picker mode in the right panel it’s about getting color info to set a parametric mask, a controlpoint,... not to evaluate the histogram.

That's a good point. I'll try flipping the histogram code so it only minds "restrict histogram to selection" if this is the primary (left panel) colorpicker. (Alternative would be some sort of customization of this behavior, but that seems way too fine grained...)

Maybe a right-click on swatch instead? [to load live sample area as the primary picker area]

This makes sense.

hovering over live point sample still shows zoomed cross

I did that on purpose, to make the picker extra-noticeable -- I thought showing a color swatch there would be confusing. I can experiment though.

I tried making the point picker outline circular, to emphasize that it (ideally) is a sample of pixels which are a sample of an image (samples all the way down). So it looks something like:

image

When zoomed in to >= 400%, it changes to a square central sample at preview pipe resolution:

image

And does expand slightly (to allow room for the sample) up to 1600%:

image

And hover of live sample behavior (here at 400%):

image

Other idea (complementary to above); currently right clicking in center view always resets area to full image. What about if you right click within a live sample, it sets current picker to same area as sample? And if overlapping samples, multiple right-clicks cycle between them. And one of the stops in the cycle is full image, so still incorporates current functionality. Right-click in center and right-click on swatch would be consistent/"intuitive".

Interesting! I'll try this. If it's not too code intensive!

Maybe there are educational opportunities here to teach newcomers about sampling colorpickers at different stages of the pipe

Another educational opportunity is to see just how untrustworthy a point sample can be, particularly from the preview pixelpipe. For example, from an X-Trans image:

image

Jiyone on IRC asked if it would be possible to sample color very early in the pipe, probably at raw black/white point or demosaic, mainly for callibrating film scans done with camera where red channel of base film needs to be in 90-100% range

If the input is demosaiced (straight RGB from a film scanner), would it be possible to move RGB Curve iop to the start of the pixelpipe? That gives you a histogram for that point in the pipe, as well as a point/area colorpicker which give numerical readouts (on a 0-255 scale...).

@dtorop
Copy link
Contributor Author

dtorop commented Aug 23, 2021

There's a mysterious build error, it looks like CI may have picked up a non-current version of a file to compile...?

There's a bunch more details changed:

  • updated the point picker's overlay to include a color swatch when it is emphasized on mouseover
  • mouseover of primary sample in left panel emphasizes the picker overlay in the center view (as already with live samples)
  • allow for adding a live sample from the current iop picker's area
  • allow for copying a live sample area to the active picker by right-clicking its swatch
  • only primary colorpicker (not module pickers) restricts the histogram/scope to the current selection area
  • eliminate the notion of a "focused" or "dimmed" primary picker: the primary picker is draggable until it is turned off or replaced by an module picker
  • when reactivating the primary picker, as with each module picker, it no longer resets but "remembers" its last location
  • when using the blend picker, its location doesn't reset when switching between blend types (e.g. RGB to JzAzBz)

This gets this close to "feature complete" (read that as "initial plan plus a bunch of ideas which came up along the way"). The one missing thing that I remember from the thread above would be to allow for right-clicking in the center view to copy a live sample's area to the active picker.

The overlays for tone equalizer and graduated density iops should be back to working.

I sped up the point picker dragging code slightly. Unfortunately, it looks like the slowdown is actually not in the pixelpipe (which does need to partially run to calculate the new sample) but in redrawing the whole center view just to update the picker overlay. This may be worse for hidpi displays. I went back to the code before this PR which also seems to me about as laggy. I notice it a lot at 400%. I'm also wondering if hiding the mouse pointer while dragging makes the lag more noticeable, as nothing now updates smoothly.

One way to test this is to set in conf ui/performance=TRUE. For me that gets rid of the laginess. Alternately, forcing _get_filtering_level() to return CAIRO_FILTER_FAST has the same effect.

If drawing is indeed the problem, then this is something to be aware of in general as a bottleneck. There may be a way to cache the most recent scaled-to-center-view version of the current image, then only apply the overlays on top, but that doesn't really get to the root of it.

There's a bunch of new internal overhaul. Mainly:

  • As before, each colorpicker widget keeps track of its own "proxy" state object. But modules no longer know about the proxy state of their current picker. The currently active colorpicker's state is stored "globally", as there is at most one active picker at any given time. This is mainly to get rid of stowing the primary color picker's proxy in the colorout module, but should generally simplify/clarify things.
  • Color profile tidying: The primary picker and live samples are taken from the preview pixelpipe in display space. Previously the RGB values were converted from display to histogram profile. Then to draw swatches in the GUI, they were converted back to display profile again. Now just use the original display profile RGB directly.
  • More color profile tidying: Use the dt_ioppr_* routines for colorspace conversion when sampling the primary picker and live samples. These have a fast matrix path and still can fall back to LittleCMS. This gets rid of a bunch of boilerplate.

No doubt things are broken, as these are so many changes!

@dtorop
Copy link
Contributor Author

dtorop commented Aug 23, 2021

CI still appears to be failing with an out-of-date version of libs/colorpicker.c, FWIW...

dtorop added 2 commits August 24, 2021 00:11
Store for dt_colorpicker_sample_t structure in dt_lib_colorpicker_t as
s/proxy_linked/primary_sample/. Use its data for picker color rgb/lab
min/max/mean and size.

Goal is not to store primary colorpicker data in colorout at all so
that it isn't tied to colorout being focused. For now it is stored in
dt_lib_colorpicker_t and in current module.

Should continue to be functional, but haven't added new functionality.

Still need to get rid of overlapping code and simplify things.

Colorpickers in iops seem to continue to work, but need to see if some
overlapping code or other test cases are necessary.

Note that per-module data still comes from dt_iop_module_t rather than
primary colorpicker.

Set primary sample point/box in rest of cases on mouse down in center
view. Note that this sets primary sample even when per-module picker
is active, in hopes that later can make primary sample give a
per-module readout.

Use primary sample's box/point data when doing color picking for it in
pixelpipe, rather than per-module sample.
The internal pixelpipe _pixelpipe_pick_from_image() previously had a
bunch of values passed to it. As these are now all in
dt_colorpicker_sample_t for both primary colorpicker and live samples,
just pass in that struct.
- Restore mean/min/max swatches to tooltip. This was lost in a
  previous commit.

Also some tidying:

- Just store 0-255 int values for RGB in histogram profile, as that is
  how they are used later.

- Straighten out some float/double math.

- Don't need to check for non-negative values when applying levels or
  rgblevels.

- Live samples in rgb curve appear to be working, so remove a FIXME

- Remove some obsolete FIXMEs in darkroom.c
@dtorop dtorop force-pushed the restrict-histogram-during-edit branch from e331f3c to 8deab03 Compare August 24, 2021 04:31
Reassure the compiler that variables are initialized.
@dtorop
Copy link
Contributor Author

dtorop commented Aug 24, 2021

I'm thinking that it's the time to be finished adding features to this PR. Any further testing/feedback much appreciated.

@TurboGit
Copy link
Member

First of all, this is a really nice work and a great addition to dt !

One comment:

  • I find the cross when hovering a point sample a bit too large (the cross is twice the size of the circle sample).

Apart from that it is ok to me and I'd like to merge this soon now for having more field testing because as you say some parts may be broken even if all my testing seems to be working fine.

@TurboGit TurboGit self-requested a review August 24, 2021 13:21
The crosshair is now 2x (rather than 3x) the regular size.
@dtorop
Copy link
Contributor Author

dtorop commented Aug 24, 2021

First of all, this is a really nice work and a great addition to dt !

Thank you!!

I find the cross when hovering a point sample a bit too large (the cross is twice the size of the circle sample).

A fair point... I added a commit to reduce it so it is 2x (rather than 3x). It does look better to me. It's easy to tune this more...

Apart from that it is ok to me and I'd like to merge this soon now for having more field testing because as you say some parts may be broken even if all my testing seems to be working fine.

Yes! For what it is worth, my greatest fear about the code is that there will be some (very subtle) breakage due to thread safety and shared data. Worst case, as far as I can tell, is that things will "self correct" as the color picker is an interactive tool, but better that things don't come to that.

I'm happy if this is merged, and then any bug reports and feature requests are steered toward me... That would also allow for another chance to clean up residual rough edges.

Generalizes configuration code.

At some point it might be nice to eliminate some of the enum
boilerplate though....
@dtorop
Copy link
Contributor Author

dtorop commented Aug 25, 2021

@TurboGit : I've found a few other quirks in this PR, particularly:

  • Initial swatch overlaid on primary picker can be blank
  • The primary picker's overlay swatch can be drawn with stale data (though it will eventually update)
  • Active eyedropper picker buttons aren't always turned off when switch image or leave darkroom view
  • It's enough for the proxy to catch DT_SIGNAL_DEVELOP_PREVIEW_PIPE_FINISHED rather than DT_SIGNAL_CONTROL_PICKERDATA_READY so long as this isn't a module colorpicker.
  • The mouse cursor flickers when dragging a point picker.

I've got fixes for all but the last of these. The last one is a mystery (apparently introduced in c259208), but I at least have a workaround.

I'm reluctant to keep adding commits to this PR, as it might complicate reviewing it and the above are more annoyances than major bugs. Would it be better to go with this PR as is, and work up a follow-up PR with fixes? Or just keep trying to fix details here?

@TurboGit
Copy link
Member

* When an module's color picker is used and "restrict histogram to selection" is enabled, the histogram is restricted based on the area of the iop's color picker.

I cannot make this to work, is that me or something is broken?

@TurboGit
Copy link
Member

There is also a regression, on the console each time I click on the global color-picker (point or area) I get:

[_transform_lcms2] transfoming from RGB to Lab (gamma )
profil de travail  non supporté, remplacé par Rec 2020 RVB !

@dtorop
Copy link
Contributor Author

dtorop commented Aug 25, 2021

There is also a regression, on the console each time I click on the global color-picker (point or area) I get:

[_transform_lcms2] transfoming from RGB to Lab (gamma )
profil de travail  non supporté, remplacé par Rec 2020 RVB !

That's not good. It must be broken with cLUT display profiles. Is it easy to send over your display profile to me so I can test? I don't have a test profile on hand here.

  • When an module's color picker is used and "restrict histogram to selection" is enabled, the histogram is restricted based on the area of the iop's color picker.

I cannot make this to work, is that me or something is broken?

I disabled that in response to #9835 (comment) from @MStraeten:

while in vectorscope displaying the picked color is fine (just the white spot) restricting the histogram when using the picker in a processing module (right panel) is strange and not useful in my opinion. If i select the restriction in the left panel it's about evaluating the selected area/point in the histogram; in color picker mode in the right panel it’s about getting color info to set a parametric mask, a controlpoint,... not to evaluate the histogram.

@TurboGit
Copy link
Member

The issue is when I set the screen profile to system and the GNOME color management has been assigned a profile created from DisplayCal. Here is such profile:

prof.icc.txt

@TurboGit
Copy link
Member

I disabled that in response to #9835 (comment)

Sorry for missing that and thanks for the clarification.

@dtorop
Copy link
Contributor Author

dtorop commented Aug 27, 2021

Here is such profile:

prof.icc.txt

Thank you for sending, that's helpful. It looks like the problem is that dt_ioppr_transform_image_colorspace() rejects CLUT profiles when doing RGB -> Lab or Lab -> RGB transformations via LittleCMS. This doesn't make sense, as LCMS is perfectly capable of doing this. And the analogous RGB -> RGB code in _transform_rgb_to_rgb_lcms2() does allow RGB CLUT profiles.

I added a commit which allows DT_PROFILE_DIRECTION_ANY profiles (rather than DT_PROFILE_DIRECTION_WORK), and this allows for doing the color work in LCMS.

I looked back through the code history, and there's no note of why RGB -> RGB code uses _ANY and Lab <-> RGB used _WORK. It's original to these functions. I looked through the other uses of dt_ioppr_transform_image_colorspace() and don't see any problems resulting from this change.

Previousely, the conversion in _transform_from_to_rgb_lab_lcms2()
would revert to Rec.2020 if the RGB profile was not a work profile.

Because dt_colorspaces_init() only allows matrix profiles as work
profiles, this means that CLUT profiles cannot be used in
_transform_from_to_rgb_lab_lcms2().

LCMS is capabable of transforming CLUT profiles, so it doesn't make
sense to not allow them in this transform. This is in line with the
behavior of _transform_rgb_to_rgb_lcms2() whioch also uses
DT_PROFILE_DIRECTION_ANY.

In case of display profile in _transform_from_to_rgb_lab_lcms2(), take
care of xprofile_lock work.

This change allows for a succinct conversion in
_pixelpipe_pick_from_image() from RGB to Lab.

Note that the equivalent code before this PR always used LittleCMS,
and used profile direction:

DT_PROFILE_DIRECTION_OUT | DT_PROFILE_DIRECTION_DISPLAY
@dtorop dtorop force-pushed the restrict-histogram-during-edit branch from 10e931f to 8dae032 Compare August 27, 2021 02:55
Copy link
Member

@TurboGit TurboGit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me. That being said I must confess that it is difficult to do a proper review as this part is very delicate and I don't have a proper full view on this. My testing are all ok and hopefully remaining glitches will be found soon and well before the 3.8 release. A big thanks for this amazing work !

@TurboGit TurboGit merged commit 9695848 into darktable-org:master Aug 27, 2021
@dtorop
Copy link
Contributor Author

dtorop commented Aug 27, 2021

@TurboGit : That's great! I absolutely agree regarding worries about fragility and proper review.

I do have a queue of fixes/improvements still in progress. I'll be working on a follow-up PR with these!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug difficulty: hard big changes across different parts of the code base documentation-complete needed documentation is merged in dtdocs feature: enhancement current features to improve feature: redesign current features to rewrite scope: codebase making darktable source code easier to manage scope: UI user interface and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

color picker: restrict histogram to selection

7 participants