Bug 281095

Summary: BQM AdjustCurve tool : curves adjustment doesn't work
Product: [Applications] digikam Reporter: Emil.s <emil>
Component: Plugin-Bqm-CurvesAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: caulier.gilles, czernitko, dariocambie, frederic.coiffier, sven.burmeister, thomas.bettler
Priority: NOR    
Version: 3.1.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 3.2.0

Description Emil.s 2011-08-31 09:28:39 UTC
Version:           2.0.0 (using KDE 4.7.0) 
OS:                Linux

I'm trying to change the curves on some images with the Digikam batch processor, but it doesn't work.
Everything seems to work, the history box reports that the images has been processed, but when viewing the output image, it looks exactly like the original. 

Reproducible: Always

Steps to Reproduce:
Open Digikam batch processor
Add images
Select "Curves adjustment", change something
Press start button...

Actual Results:  
You get a copy of the original image

Expected Results:  
You get an image that has been adjusted like you have set the curves.
Comment 1 caulier.gilles 2011-08-31 12:47:13 UTC
Git commit 984dcf90e526f427d53976717beb14b78b08b027 by Gilles Caulier.
Committed on 31/08/2011 at 14:45.
Pushed by cgilles into branch 'master'.

fix curve adjust BQM tool t use right color depth with image to process
BUGS: 281095

M  +24   -25   utilities/queuemanager/basetools/color/curvesadjust.cpp
M  +1    -1    utilities/queuemanager/basetools/color/curvesadjust.h
M  +3    -0    libs/dimg/filters/curves/curvesfilter.cpp

http://commits.kde.org/digikam/984dcf90e526f427d53976717beb14b78b08b027
Comment 2 caulier.gilles 2011-09-04 08:06:35 UTC
I re-open this file.

It still a problem with curve applied in BQM in FREE edition mode. SMOTH edition work fine.

It's due to a lack of information passed from an edition mode to another one.

I will fix it to 2.2.0 release (too late for 2.1.0)

Gilles Caulier
Comment 3 Marcel Wiesweg 2011-11-05 13:40:59 UTC
*** Bug 284391 has been marked as a duplicate of this bug. ***
Comment 4 Marcel Wiesweg 2011-11-05 13:41:51 UTC
Normally, the ImageCurvesFilter should convert the ImageCurves object to the necessary bits depth with ImageCurves::fillFromOtherCurves, which produces debug info. Anyone already found out where exactly the problem is?
Comment 5 caulier.gilles 2011-11-05 13:58:26 UTC
Marcel,

Yes i found it. Let's me some time to find my bookmark in code...

Gilles
Comment 6 Frédéric COIFFIER 2011-12-13 18:32:41 UTC
The problems seems to be still present in digikam-2.4.1 with kipi-plugins-2.4.1.

Do you confirm ?
Comment 7 caulier.gilles 2011-12-13 19:42:06 UTC
yes, i don't have fixed it...

Gilles Caulier
Comment 8 Petr Černý 2012-02-03 08:04:57 UTC
The bug seems to be still present in DigiKam 2.5.0 (KDE 4.7.4). Is there any workaround to be able to batch process B&W filter before the bug gets closed? Or is there any way I can help solving the bug?
Comment 9 Marcel Wiesweg 2013-03-21 19:44:56 UTC
Any testing here with a recent version?
Comment 10 Petr Černý 2013-03-21 21:53:18 UTC
Unfortunately I don't have latest version (I would have to recompile whole KDE), but with 2.9.0 the bug was still present.
Comment 11 Dario Cambié 2013-03-21 22:57:05 UTC
If to reproduce it's enough to try 'curves adjust' on a photo in batch queue manager I can't reproduce (current master, 5673a4b).

I haven't understood the difference between "BQM in FREE/SMOTH edition mode" mentioned earlier though.
Comment 12 Frédéric COIFFIER 2013-03-22 08:37:40 UTC
"Curve adjust" works in Digikam 3.0 but "B&W convert" is still broken :

- Open the "Batch Queue Manager"
- Add "B&W convert" (without modifying anything)
- Run

--> All the generated images are black
Comment 13 caulier.gilles 2013-03-22 09:14:13 UTC
Marcel,

If you look my previous comment #2 and #5, the problem still here. I don't have fixed code.

It's due to a lack of curve data transformation code between smooth and draw mode. If i remember, one transformation is missing, which make black image result.

Curve data are managed in draw when image is processed. Why ? to not lack any information. When you play curve in smooth mode (16 points max) and must be transformed as draw. this want mean one point for one value under 16 bits : 65536 points. This is 16 bits in all cases and switch from 8 bits to 16 bits transformation must be done (and vis-versa).

If i remember this last transformation is missing.

Gilles Caulier
Comment 14 Marcel Wiesweg 2013-03-22 21:04:48 UTC
ImageCurves::fillFromOtherCurves is not sufficient for 8 <-> 16 bit conversion?
Comment 15 caulier.gilles 2013-03-22 21:12:37 UTC
I think no, if i remember my investigations. Something is missing in source code to convert from smooth to draw mode and vis versa.
Comment 16 Marcel Wiesweg 2013-03-24 18:19:44 UTC
That is not implemented, and FREE cannot be converted to SMOOTH mode. Why would we need it? Either the curve is created by the user in FREE, or in SMOOTH mode.
Comment 17 caulier.gilles 2013-03-25 12:18:13 UTC
Marcel,

I just tested. There are two problems :

1/ In BQM, Adjust curves tool do not take effect on image when it's processed as FREE mode. In SMOOTH mode no problem. To reproduce it's very simple : Load few JPEG in BQM, assign curves adjust + PNG export tools, change curve settings to reduce luminosity (just drop-down curve with one central point to the bottom). In a first time use SMOOTH mode and look result. All is fine in target image. Now, just switch mode from SMOOTH to DRAW. central point disappear. Remove previous target PNG and run again the queue. Look the result : source and target image have the same luminosity.

2/ In BQM, Convert to B&W produce black hole images when curve adjustments is used. Use same queue context than 1/ and replace Adjust Curves tool  by Convert to B&W. In B&W settings use Generic film + No Lens Filter + No Tone Filter. Just go to Luminosity curve and drop-down curve in SMOOTH mode to reduce luminosity. Run queue, and look the result : all target image are black holes. Now switch curve from SMOOTH to FREE and run again the queue : All image are converted to B&W but luminosity is not changed.

Gilles Caulier
Comment 18 caulier.gilles 2013-03-26 05:20:12 UTC
Marcel,

Another point : If you test image editor tool (B&W and Adjust Curves), no dysfunction are visible. Only BQM tools are broken. The reason about is that BQM tools settings widget pass curves parameters to BQM action thread using a QPolygon container for each color channel to apply (See CurvesContainer API).

Format of data osted in QPolygon depand of curves widget settings of course. In BQM, it's always set as 16bits color depth, to be compatible with all image type (we know the color depth of image only when queue is processed). Also, FREE or SMOOTH mode depend of user choice done in GUI.

Action thread recieve QPolygon data and must convert curves settings to the right format, compatible with image properties just loaded in BQM tool to be processed. It's at this time that curves conversion are processed and failed.

Gilles
Comment 19 caulier.gilles 2013-04-01 13:07:33 UTC
*** Bug 317658 has been marked as a duplicate of this bug. ***
Comment 20 Marcel Wiesweg 2013-05-01 15:31:38 UTC
Git commit 76de9f0a1f21a28218bc4b24dbea5ede0d3b3388 by Marcel Wiesweg.
Committed on 01/05/2013 at 16:30.
Pushed by mwiesweg into branch 'master'.

Fix curve conversion in FREE mode from 16 to 8 bit
FIXED-IN: 3.2.0

M  +1    -1    libs/dimg/filters/curves/imagecurves.cpp

http://commits.kde.org/digikam/76de9f0a1f21a28218bc4b24dbea5ede0d3b3388
Comment 21 Marcel Wiesweg 2013-05-01 15:54:40 UTC
Git commit 85622209f06f61efb7dcce98508e7f9119294f2e by Marcel Wiesweg.
Committed on 01/05/2013 at 16:52.
Pushed by mwiesweg into branch 'master'.

Properly initialize a smooth curve to be linear. Last point was set as first point.
The bug only appeared in BQM's B&W conversion which only uses the luminosity channel,
taking the default constructed CurvesContainer for the other colors.

M  +1    -1    libs/dimg/filters/curves/curvescontainer.cpp
M  +1    -1    libs/dimg/filters/curves/imagecurves.cpp

http://commits.kde.org/digikam/85622209f06f61efb7dcce98508e7f9119294f2e
Comment 22 Thomas Bettler 2013-05-01 21:18:47 UTC
Many thanks Marcel! This patch works for me.
Comment 23 Veaceslav Munteanu 2013-05-02 16:08:10 UTC
Git commit 9d109067cd2237840373b6857e8c68d608f1015b by Veaceslav Munteanu, on behalf of Marcel Wiesweg.
Committed on 01/05/2013 at 16:30.
Pushed by munteanu into branch 'picassafacetag'.

Fix curve conversion in FREE mode from 16 to 8 bit
FIXED-IN: 3.2.0

M  +1    -1    libs/dimg/filters/curves/imagecurves.cpp

http://commits.kde.org/digikam/9d109067cd2237840373b6857e8c68d608f1015b
Comment 24 Veaceslav Munteanu 2013-05-02 16:08:12 UTC
Git commit 0ac25a4a0d77b58fc8dd76d9abee3ba14fa0a4eb by Veaceslav Munteanu, on behalf of Marcel Wiesweg.
Committed on 01/05/2013 at 16:52.
Pushed by munteanu into branch 'picassafacetag'.

Properly initialize a smooth curve to be linear. Last point was set as first point.
The bug only appeared in BQM's B&W conversion which only uses the luminosity channel,
taking the default constructed CurvesContainer for the other colors.

M  +1    -1    libs/dimg/filters/curves/curvescontainer.cpp
M  +1    -1    libs/dimg/filters/curves/imagecurves.cpp

http://commits.kde.org/digikam/0ac25a4a0d77b58fc8dd76d9abee3ba14fa0a4eb