Desmis 82129b304d
Re-open Generalized Hyperbolic Stretch (#7251)
* GHS GUI first step

* GHS GUI first step

* GUI step 3

* Hide show ghsmethod

* Siril functions for ghs

* Init ghs in iplocallab

* ghs step 2

* ghs step 4

* Comment copyright Pixlnsight 2021

* Smooth highlights and tooltips

* Enabled saturation and luminance ghs mode

* First tooltip

* Ghs tooltips

* Remove wrong packstart inverssh

* Change labels and tooltips

* Disabled mask in global and other improvments

* Comment code

* appimage and windows yml ghs

* Change tooltip

* Ghsmethod hue and change tolltips

* Change tooltip

* Inverse Stretch step 1

* Inverse GHS

* GHS tooltips

* Change tooltips

* Change tooltip

* Linear black point

* Small change to blackpoint

* Change tooltip

* Clean and comment code

* forgotten GHS highlight attenuation msg in history

* Comment code with Transformation equations

* Change tooltip

* Wrong default value balck point

* Comment code iplocallab

* Ghs curve step 1

* GHS curve step 2

* Show GHS setting in a Curve Box

* Tooltip for ghs S curve

* Disabled warning in compilation simpleprocess

* Simplified code part 1

* Simplified code GHS graph part 2

* Improve black point with negatives values

* Improve BP and tooltip

* Listener enable only with GHS

* White point for GHS

* Change label and tooltip

* Improve behavior white point and black point

* Link sliders ghs_SP ghs_LP ghs_HP and change code to avoid balck screen

* hide unused button in diagonal curve GHS

* prevents the GHS representation in S from displaying artifacts if ghs-d=0

* Change tooltips

* Improvment and tooltips

* Forgotten tooltip

* Improve GUI GHS S curve - change tooltips

* Set transition gray areas in S curve GHS with values of the RT-spot

* Change label GHS

* setlogscale blackpoint and symmetry

* Set recursive reference enable by default in controlspotpanel

* Change lastlocalCurvesDir Dirghs in locallabtools and options - change labels

* Added in converttonormal ghsMode.. not sure if this is useful

* DIY to make GHS curve work without the choices

* Change RGB calculation with luminance function working profile

* 5 modes GHS method

* Label to show datas clipped Black point and White point

* Various change white point tooltips

* Bad behavior wp bp labels

* Small change to improccordinator call to ghschanged ghsbwchanged

* Set log scale ghs_D

* Hide Graduated filter if GHS enable

* Luminance Lab in ghsmethod

* Lab slope factor step 1

* Slope and Chromaticity GHS improvments

* Fixed bad sqrt line 17477 iplocallab

* Workaround linear GHS - re-enable Graduated filer GHS

* Change limits slope lab factor

* Ghs chromaticity Lab (Lch)

* Improve ghs chromaticity

* Change labels and tooltips Lab chroma

* Slope Lab to 100

* Noise and saturation RGB

* Saturation RGB standard and labels

* Change histogram and navigator panel without gamma when using working profile

* Remove gray in GHS curve

* Local contrast a minima

* Regularization stretch

* Improve Graduated Filter in all cases GHS Color and Light etc.

* Improves nlmeans to reduce noise after GHS

* Change to GF - tooltip Nlmeans

* Added oW oH tW tH etc.

* Added call GF

* tX tY for previewProps

* Comment code GF

* Improve local contrast ghs

* Change norm to norm2

* Improve GUI mode complexity and Lab GHS

* Show values BP WP in GUI

* Labgrid ghs step 1

* Labgrid for simulation GHS - step 2

* More points for Labgrid ghs

* Clean and comment code

* Fixed crash in inverse GHS white point - set to 10 points for GSH simulation

* Change to black point in inverse GHS

* Intilialize simulation with nothing if new spot

* Remove curve GHS - optimize code simulation - improve GUI

* set ghs default - fixed crash is case HP SP LP

* Fixed crash - I hope in inverse GHS

* Simplify WP and BP limits to avoid crash in inverse GHS

* Clean code with ghscurve - ghsshape

* Change tooltips

* Change to D - GUI - comment code

* Simulation with 4 more points

* Best simulation with point 0.05 and 0.95

* Clean code - change for crsah in Inverse GHS

* Show values WP and BP

* Change tooltips

* Midtones after GHS

* Modification code WP BP

* Tests changes in settings for transition and Shape detection - see Preferences

* Change order labels luma chroma hue

* Fixed bad behavior localllistener denchanged in dcrop.cc

* Save work

* Work on graduated filter

* Improve a little graduated filter SH and others...

* 3 configurations tests graduated filter SH plain image - color more sk - exposure normal

* Forgotten code ...

* Change improccordinator parameter

* Save work printf parameters GF

* New test for GF

* Hide plain image calculation GF

* Small chnages and comment code

* Change tooltip exp graduated filter

* Change tooltip exp graduated filter

* Save work

* Change GF for some tools only in Global and Fullimage - test for GF SH mode plain image

* Fixed crash and GUI part 1

* Others change GF

* Change label - allow GF plain image in SH

* Change GF with cx cy sk

* Adapt locallabtool and locallabtools2 to GF

* Clean code

* GF wavelet only in fullimage and global

* GF - Empirical correction to cx and cy in function of sk

* Change label GHS and position in GUI

* Fixed Black point bad behavior history - an oversight may be age

* Change real strength of GF - to look like GF main

* Include ksk - Skip correction in all code GF

* Passed other parameters to try

* New parameter for GF

* Change position graph-curv ghs and labels black and white point

* Change behavior and default value white point

* Save provisory work

* Save provisory work

* Curve GHS with 21 points including 0 and 1

* Two prameters added to change behavior GF - rationalize their using

* Change Black point direction

* Change range black-point for negatives values - chnage tooltips

* Change tooltips

* Various change to avoid crash and settings defaults

* Disabled showmùaskmethod - set max white point to 5

* Fixed bad behavior when change fullimage to global for mask

* Clean comment code

* Fixed - I hope - bad behavior when we go from Fullimage to Global and vice versa

* Fixed crash in output tif and show time to calculate WP and BP

* Change tooltip BP and WP

* Change tooltips BP WP

* move GF after GHS so as not to influence BP and WP

* Clean code

* Disable all mask and modifications in Global but remain active in fullimage and normal

* Change tooltip graduated filter

* Restore GF in normal mode - and increases GF strength as before

* Clean code locallabtools 1 2

* Comment in calclocalGradientParams in iplocallab for changes in Graduated F

* Change convention labels - tooltips

* Change tooltips

* improves (I hope) the readability of the tooltips

* Remove with comment change complexity in Settings

* Improve settings BP WP - improve tooltips

* Refactor GHS curve and increase resolution

Simplify how the curve parameters are passed to the drawing area.

Use up to 400 line segments to draw the curve.

* Update GHS curve tooltip

Remove statement regarding the number of points used because it is no
longer accurate.

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Change Luma with Lightness

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Update rtdata/languages/default

Co-authored-by: Lawrence37 <45837045+Lawrence37@users.noreply.github.com>

* Remove warnings in icmpanel

* Changes suggested by Lawrence37

* GHS - Hide inverse always show in some cases - improve tooltip BP WP

* Change tooltip

* Change tooltip

* Small changes

* Change tootip suggested by Lawrence37 - set midtones and LC set_sensitive in function of D

* Add tooltip as suggest by Lawrence37 for LC and midtones

* Remove tooltip on Frame LC and Midtones

* Remove all traces toottips frame LD and Midtones

* set sensitive BLP and HLP to false if stretch = 0

* Change Beep6581 to Rawtherapee in appimage.yml and Windows.yml

* Hide LC and midtones when Stretch = 0

* Clean up Generalized Hyperbolic Stretch code

Convert some ints into enum classes.

Replace new/delete with std::unique_ptr for image.

Remove unused GHS parameters in ProcParams and ParamsEdited which were
used to draw the curve.

Revert changes to the curve editors because they are not needed.

Simplify the drawing of the curve background for efficiency.

Restore the const-ness of some variables.

* Change appimage.yml and windows.yml

---------

Co-authored-by: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com>
2025-03-29 18:07:58 +01:00

836 lines
36 KiB
C++

/* -*- C++ -*-
*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <array>
#include <cstdint>
#include <ctime>
#include <string>
#include <memory>
#include <glibmm/ustring.h>
#include <lcms2.h>
#include "iimage.h"
#include "imageformat.h"
#include "procevents.h"
#include "settings.h"
#include "rtgui/threadutils.h"
/**
* @file
* This file contains the main functionality of the RawTherapee engine.
*
*/
template<typename T>
class array2D;
template<typename T>
class LUT;
using LUTu = LUT<uint32_t>;
class EditDataProvider;
class GainMap;
namespace rtengine
{
enum RenderingIntent : int;
namespace procparams
{
class ProcParams;
class IPTCPairs;
struct RAWParams;
struct ColorManagementParams;
struct CropParams;
enum class ToneCurveMode : int;
}
class IImage8;
class IImage16;
class IImagefloat;
class ImageSource;
class TweakOperator;
/**
* This class provides functions to obtain exif and IPTC metadata information
* from any of the sub-frame of an image file
*/
class FramesMetaData
{
public:
/** @return Returns the number of frame contained in the file based on Metadata */
virtual unsigned int getFrameCount() const = 0;
/** Checks the availability of exif metadata tags.
* @return Returns true if image contains exif metadata tags */
virtual bool hasExif() const = 0;
/** @return a struct containing the date and time of the image */
virtual tm getDateTime() const = 0;
/** @return a timestamp containing the date and time of the image */
virtual time_t getDateTimeAsTS() const = 0;
/** @return the ISO of the image */
virtual int getISOSpeed() const = 0;
/** @return the F number of the image */
virtual double getFNumber() const = 0;
/** @return the focal length used at the exposure */
virtual double getFocalLen() const = 0;
/** @return the focal length in 35mm used at the exposure */
virtual double getFocalLen35mm() const = 0;
/** @return the focus distance in meters, 0=unknown, 10000=infinity */
virtual float getFocusDist() const = 0;
/** @return the shutter speed */
virtual double getShutterSpeed() const = 0;
/** @return the exposure compensation */
virtual double getExpComp() const = 0;
/** @return the maker of the camera */
virtual std::string getMake() const = 0;
/** @return the model of the camera */
virtual std::string getModel() const = 0;
std::string getCamera() const
{
return getMake() + " " + getModel();
}
/** @return the lens on the camera */
virtual std::string getLens() const = 0;
/** @return the orientation of the image */
virtual std::string getOrientation() const = 0;
/** @return the rating of the image */
virtual int getRating() const = 0;
/** @return true if the file is a PixelShift shot (Pentax and Sony bodies) */
virtual bool getPixelShift () const = 0;
/** @return false: not an HDR file ; true: single or multi-frame HDR file (e.g. Pentax HDR raw file or 32 bit float DNG file or Log compressed) */
virtual bool getHDR() const = 0;
/** @return true if the file is a DNG file */
virtual bool getDNG() const = 0;
/** @return false: not an HDR file ; true: single or multi-frame HDR file (e.g. Pentax HDR raw file or 32 bit float DNG file or Log compressed) */
virtual std::string getImageType() const = 0;
/** @return the sample format based on MetaData */
virtual IIOSampleFormat getSampleFormat() const = 0;
/** Functions to convert between floating point and string representation of shutter and aperture */
static std::string apertureToString (double aperture);
/** Functions to convert between floating point and string representation of shutter and aperture */
static std::string shutterToString (double shutter);
/** Functions to convert between floating point and string representation of shutter and aperture */
static double apertureFromString (std::string shutter);
/** Functions to convert between floating point and string representation of shutter and aperture */
static double shutterFromString (std::string shutter);
/** Functions to convert between floating point and string representation of exposure compensation */
static std::string expcompToString (double expcomp, bool maskZeroexpcomp);
virtual ~FramesMetaData () = default;
/** Reads metadata from file.
* @param fname is the name of the file
* @param rml is a struct containing information about metadata location of the first frame.
* Use it only for raw files. In caseof jpgs and tiffs pass a NULL pointer.
* @param firstFrameOnly must be true to get the MetaData of the first frame only, e.g. for a PixelShift file.
* @return The metadata */
static FramesMetaData* fromFile(const Glib::ustring& fname);
virtual Glib::ustring getFileName() const = 0;
virtual std::uint32_t getFixBadPixelsConstant() const = 0;
virtual bool hasFixBadPixelsConstant() const = 0;
virtual std::vector<GainMap> getGainMaps() const = 0;
virtual void getDimensions(int &w, int &h) const = 0;
};
/** This listener interface is used to indicate the progress of time consuming operations */
class ProgressListener
{
public:
virtual ~ProgressListener() = default;
/** This member function is called when the percentage of the progress has been changed.
* @param p is a number between 0 and 1 */
virtual void setProgress(double p) = 0;
/** This member function is called when a textual information corresponding to the progress has been changed.
* @param str is the textual information corresponding to the progress */
virtual void setProgressStr(const Glib::ustring& str) = 0;
/** This member function is called when the state of the processing has been changed.
* @param inProcessing =true if the processing has been started, =false if it has been stopped */
virtual void setProgressState(bool inProcessing) = 0;
/** This member function is called when an error occurs during the operation.
* @param descr is the error message */
virtual void error(const Glib::ustring& descr) = 0;
};
class ImageSource;
/**
* This class represents an image loaded into the memory. It is the basis of further processing.
* The embedded icc profile and metadata information can be obtained through this class, too.
*/
class InitialImage
{
public:
/** Returns the file name of the image.
* @return The file name of the image */
virtual Glib::ustring getFileName() const = 0;
/** Returns the embedded icc profile of the image.
* @return The handle of the embedded profile */
virtual cmsHPROFILE getEmbeddedProfile() const = 0;
/** Returns a class providing access to the exif and iptc metadata tags of all frames of the image.
* @return An instance of the FramesMetaData class */
virtual const FramesMetaData *getMetaData() const = 0;
/** This is a function used for internal purposes only. */
virtual ImageSource* getImageSource () = 0;
/** This class has manual reference counting. You have to call this function each time to make a new reference to an instance. */
virtual void increaseRef () {}
/** This class has manual reference counting. You have to call this function each time to remove a reference
* (the last one deletes the instance automatically). */
virtual void decreaseRef () {}
virtual ~InitialImage () {}
/** Loads an image into the memory.
* @param fname the name of the file
* @param isRaw shall be true if it is a raw file
* @param errorCode is a pointer to a variable that is set to nonzero if an error happened (output)
* @param pl is a pointer pointing to an object implementing a progress listener. It can be NULL, in this case progress is not reported.
* @return an object representing the loaded and pre-processed image */
static InitialImage* load (const Glib::ustring& fname, bool isRaw, int* errorCode, ProgressListener* pl = nullptr);
};
/** When the preview image is ready for display during staged processing (thus the changes have been updated),
* the staged processor notifies the listener class implementing a PreviewImageListener.
* It is important to note that the file passed to the listener can be used in a shared manner (copying it is not
* needed) as long as the mutex corresponding to the image is used every time the image is accessed.
* If the scale of the preview image is >1, no sharpening, no denoising and no cropping is applied, and
* the transform operations (rotate, c/a, vignetting correction) are performed using a faster less quality algorithm.
* The image you get with this listener is created to display on the monitor (monitor profile has been already applied). */
class PreviewImageListener
{
public:
virtual ~PreviewImageListener() = default;
/** With this member function the staged processor notifies the listener that it allocated a new
* image to store the end result of the processing. It can be used in a shared manner.
* @param img is a pointer to the image
* @param scale describes the current scaling applied compared to the 100% size (preview scale)
* @param cp holds the coordinates of the current crop rectangle */
virtual void setImage(IImage8* img, double scale, const procparams::CropParams& cp) = 0;
/** With this member function the staged processor notifies the listener that the image passed as parameter
* will be deleted, and no longer used to store the preview image.
* @param img the pointer to the image to be destroyed. The listener has to free the image! */
virtual void delImage(IImage8* img) = 0;
/** With this member function the staged processor notifies the listener that the preview image has been updated.
* @param cp holds the coordinates of the current crop rectangle */
virtual void imageReady(const procparams::CropParams& cp) = 0;
};
/** When the detailed crop image is ready for display during staged processing (thus the changes have been updated),
* the staged processor notifies the listener class implementing a DetailedCropListener.
* It is important to note that the file passed to the listener can <b>not</b> be used in a shared manner, the class
* implementing this interface has to store a copy of it. */
class DetailedCropListener
{
public:
virtual ~DetailedCropListener() = default;
/** With this member function the staged processor notifies the listener that the detailed crop image has been updated.
* @param img is a pointer to the detailed crop image */
virtual void setDetailedCrop(
IImage8* img,
IImage8* imgtrue,
const procparams::ColorManagementParams& cmp,
const procparams::CropParams& cp,
int cx,
int cy,
int cw,
int ch,
int skip
) = 0;
virtual void getWindow(int& cx, int& cy, int& cw, int& ch, int& skip) = 0;
};
/** This listener is used when the full size of the final image has been changed (e.g. rotated by 90 deg.) */
class SizeListener
{
public:
virtual ~SizeListener() = default;
/** This member function is called when the size of the final image has been changed
* @param w is the width of the final image (without cropping)
* @param h is the height of the final image (without cropping)
* @param ow is the width of the final image (without resizing and cropping)
* @param oh is the height of the final image (without resizing and cropping) */
virtual void sizeChanged(int w, int h, int ow, int oh) = 0;
};
class HistogramObservable;
/** This listener is used when the histogram of the final image has changed. */
class HistogramListener
{
public:
virtual ~HistogramListener() = default;
/** This member function is called when the histogram of the final image has changed.
* @param histRed is the array of size 256 containing the histogram of the red channel
* @param histGreen is the array of size 256 containing the histogram of the green channel
* @param histBlue is the array of size 256 containing the histogram of the blue channel
* @param histLuma is the array of size 256 containing the histogram of the luminance channel
* other for curves backgrounds, histRAW is RAW without colors */
virtual void histogramChanged(
const LUTu& histRed,
const LUTu& histGreen,
const LUTu& histBlue,
const LUTu& histLuma,
const LUTu& histToneCurve,
const LUTu& histLCurve,
const LUTu& histCCurve,
const LUTu& histLCAM,
const LUTu& histCCAM,
const LUTu& histRedRaw,
const LUTu& histGreenRaw,
const LUTu& histBlueRaw,
const LUTu& histChroma,
const LUTu& histLRETI,
int vectorscopeScale,
const array2D<int>& vectorscopeHC,
const array2D<int>& vectorscopeHS,
int waveformScale,
const array2D<int>& waveformRed,
const array2D<int>& waveformGreen,
const array2D<int>& waveformBlue,
const array2D<int>& waveformLuma
) = 0;
/** Tells which observable is notifying the listener. */
virtual void setObservable(HistogramObservable* observable) = 0;
/** Returns if the listener wants the histogram to be updated. */
virtual bool updateHistogram(void) const = 0;
/** Returns if the listener wants the raw histogram to be updated. */
virtual bool updateHistogramRaw(void) const = 0;
/** Returns if the listener wants the H-C vectorscope to be updated. */
virtual bool updateVectorscopeHC(void) const = 0;
/** Returns if the listener wants the H-S vectorscope to be updated. */
virtual bool updateVectorscopeHS(void) const = 0;
/** Returns if the listener wants the waveform to be updated. */
virtual bool updateWaveform(void) const = 0;
};
class HistogramObservable
{
public:
/** Tells the observable to update the histogram data. */
virtual void requestUpdateHistogram() = 0;
/** Tells the observable to update the raw histogram data. */
virtual void requestUpdateHistogramRaw() = 0;
/** Tells the observable to update the H-C vectorscope data. */
virtual void requestUpdateVectorscopeHC() = 0;
/** Tells the observable to update the H-S vectorscope data. */
virtual void requestUpdateVectorscopeHS() = 0;
/** Tells the observable to update the waveform data. */
virtual void requestUpdateWaveform() = 0;
};
/** This listener is used when the auto exposure has been recomputed (e.g. when the clipping ratio changed). */
class AutoExpListener
{
public:
virtual ~AutoExpListener() = default;
/** This member function is called when the auto exposure has been recomputed.
* @param brightness is the new brightness value (in logarithmic scale)
* @param bright is the new ...
* @param black is the new black level (measured in absolute pixel data)
* @param contrast is the new contrast values
* @param hlcompr is the new highlight recovery amount
* @param hlcomprthresh is the new threshold for hlcompr
* @param hlrecons set to true if HighLight Reconstruction is enabled */
virtual void autoExpChanged(double brightness, int bright, int contrast, int black, int hlcompr, int hlcomprthresh, bool hlrecons) = 0;
virtual void autoMatchedToneCurveChanged(procparams::ToneCurveMode curveMode, const std::vector<double>& curve) = 0;
};
class AutoCamListener
{
public :
virtual ~AutoCamListener() = default;
virtual void autoCamChanged(double ccam, double ccamout) = 0;
virtual void adapCamChanged(double cadap) = 0;
virtual void ybCamChanged(int yb) = 0;
virtual void wbCamChanged(double tem, double tin, bool autotemp) = 0;
};
class AutoBlackListener
{
public :
virtual ~AutoBlackListener() = default;
virtual void autoBlackChanged(double reddeha, double greendeha, double bluedeha) = 0;
};
class AutoBlackxListener
{
public :
virtual ~AutoBlackxListener() = default;
virtual void autoBlackxChanged(double reddeha, double greendeha, double bluedeha) = 0;
};
class AutoChromaListener
{
public :
virtual ~AutoChromaListener() = default;
virtual void chromaChanged(double autchroma, double autred, double autblue) = 0;
virtual void noiseChanged(double nresid, double highresid) = 0;
virtual void noiseTilePrev(int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP) = 0;
};
class RetinexListener
{
public:
virtual ~RetinexListener() = default;
virtual void minmaxChanged(double cdma, double cdmin, double mini, double maxi, double Tmean, double Tsigma, double Tmin, double Tmax) = 0;
};
class LocallabListener
{
public:
struct locallabRef {
double huer;
double lumar;
double chromar;
float fab;
};
struct locallabRetiMinMax {
double cdma;
double cdmin;
double mini;
double maxi;
double Tmean;
double Tsigma;
double Tmin;
double Tmax;
};
struct locallabDenoiseLC {
double highres;
double nres;
double highres46;
double nres46;
double Lhighres;
double Lnres;
double Lhighres46;
double Lnres46;
};
struct locallabcieBEF {
double blackevbef;
double whiteevbef;
double sourcegbef;
double sourceabbef;
double targetgbef;
bool autocomputbef;
bool autociebef;
double jz1bef;
};
struct locallabcieLC {
double redxlc;
double redylc;
double grexlc;
double greylc;
double bluxlc;
double bluylc;
double wxlc;
double wylc;
double meanxlc;
double meanylc;
double meanxelc;
double meanyelc;
int primlc;
double slopeglc;
bool linkrgblc;
};
struct locallabshGHSbw {//To draw GHS S curve
int ghsbw[2];
double ghsbwvalue[2];
};
//select spot settings
struct locallabsetLC {
int mainf;
bool iscolo;
bool iss;
bool isvi;
bool isexpo;
bool issof;
bool isblu;
bool isto;
bool isre;
bool isshar;
bool iscon;
bool iscbd;
bool islo;
bool isma;
bool isci;
};
struct locallabcieSIG {
double contsigq;
double lightsigq;
};
virtual ~LocallabListener() = default;
// virtual void refChanged(const std::vector<locallabRef> &ref, int selspot) = 0;
virtual void minmaxChanged(const std::vector<locallabRetiMinMax> &minmax, int selspot) = 0;
virtual void denChanged(const std::vector<locallabDenoiseLC> &denlc, int selspot) = 0;
virtual void cieChanged(const std::vector<locallabcieLC> &cielc, int selspot) = 0;
virtual void ghsbwChanged(const std::vector<locallabshGHSbw> &shghsbw, int selspot) = 0;
virtual void maiChanged(const std::vector<locallabsetLC> &csetlc, int selspot) = 0;
virtual void sigChanged(const std::vector<locallabcieSIG> &ciesig, int selspot) = 0;
virtual void ciebefChanged(const std::vector<locallabcieBEF> &ciebef, int selspot) = 0;
virtual void refChanged2(float *huerefp, float *chromarefp, float *lumarefp, float *fabrefp, int selspot) = 0;
// virtual void mainChanged(int spottype, int selspot, bool iscolor, bool issh, bool isvib, bool isexpos, bool issoft, bool isblur, bool istom, bool isret, bool issharp, bool iscont, bool iscbdl, bool islog, bool ismas, bool iscie) = 0;
virtual void scopeChangedcol(int scope, int selspot, bool enab) = 0;
virtual void scopeChangedsh(int scope, int selspot, bool enab) = 0;
virtual void scopeChangedvib(int scope, int selspot, bool enab) = 0;
virtual void scopeChangedset(int scope, int selspot, bool enab) = 0;
};
class AutoColorTonListener
{
public:
virtual ~AutoColorTonListener() = default;
virtual void autoColorTonChanged(int bwct, int satthres, int satprot) = 0;
};
class AutoprimListener
{
public:
virtual ~AutoprimListener() = default;
virtual void primChanged(float rx, float ry, float bx, float by, float gx, float gy) = 0;
virtual void iprimChanged(float r_x, float r_y, float b_x, float b_y, float g_x, float g_y, float w_x, float w_y, float m_x, float m_y) = 0;
virtual void wavlocChanged(double nlevel, double nmax, bool curveloc) = 0;
};
class AutoBWListener
{
public:
virtual ~AutoBWListener() = default;
virtual void BWChanged(double redbw, double greenbw, double bluebw) = 0;
};
class AutoWBListener
{
public:
enum class AWBMode {
NONE,
RGB_GREY,
TEMP_CORRELATION_NON_RAW,
TEMP_CORRELATION_RAW,
};
virtual ~AutoWBListener() = default;
virtual void WBChanged(int met, double temp, double green, double rw, double gw, double bw, float temp0, float delta, int bia, int dread, float studgood, float minchrom, int kmin, float histmin, float histmax, AWBMode aWBMode) = 0;
};
class FrameCountListener
{
public:
virtual ~FrameCountListener() = default;
virtual void FrameCountChanged(int n, int frameNum) = 0;
};
class FlatFieldAutoClipListener
{
public:
virtual ~FlatFieldAutoClipListener() = default;
virtual void flatFieldAutoClipValueChanged(int n) = 0;
};
class ImageTypeListener
{
public:
virtual ~ImageTypeListener() = default;
virtual void imageTypeChanged(bool isRaw, bool isBayer, bool isXtrans, bool is_Mono = false, bool isGainMapSupported = false) = 0;
};
class AutoContrastListener
{
public :
virtual ~AutoContrastListener() = default;
virtual void autoContrastChanged (double autoContrast) = 0;
};
class AutoRadiusListener
{
public :
virtual ~AutoRadiusListener() = default;
virtual void autoRadiusChanged (double autoRadius) = 0;
};
class WaveletListener
{
public:
virtual ~WaveletListener() = default;
virtual void wavChanged(double nlevel) = 0;
};
class FilmNegListener
{
public:
virtual ~FilmNegListener() = default;
virtual void filmRefValuesChanged(const procparams::FilmNegativeParams::RGB &refInput, const procparams::FilmNegativeParams::RGB &refOutput) = 0;
};
/** This class represents a detailed part of the image (looking through a kind of window).
* It can be created and destroyed with the appropriate members of StagedImageProcessor.
* Several crops can be assigned to the same image. */
class DetailedCrop
{
public:
virtual ~DetailedCrop() {}
/** Sets the window defining the crop. */
virtual void setWindow (int cx, int cy, int cw, int ch, int skip) {}
/** First try to update (threadless update). If it returns false, make a full update */
virtual bool tryUpdate ()
{
return false;
}
/** Perform a full recalculation of the part of the image corresponding to the crop. */
virtual void fullUpdate () {}
/** Sets the listener of the crop. */
virtual void setListener (DetailedCropListener* il) {}
/** Destroys the crop. */
virtual void destroy () {}
};
/** This is a staged, cached image processing manager with partial image update support. */
class StagedImageProcessor
{
public:
/** Returns the initial image corresponding to the image processor.
* @return the initial image corresponding to the image processor */
virtual InitialImage* getInitialImage () = 0;
/** Set the TweakOperator
* @param tOperator is a pointer to the object that will alter the ProcParams for the rendering */
virtual void setTweakOperator (TweakOperator *tOperator) = 0;
/** Unset the TweakOperator
* @param tOperator is a pointer to the object that were altering the ProcParams for the rendering
* It will only unset the tweak operator if tOperator is the same than the currently set operator.
* If it doesn't match, the currently set TweakOperator will remain set. */
virtual void unsetTweakOperator (TweakOperator *tOperator) = 0;
/** Returns the current processing parameters.
* Since the ProcParams can be tweaked by a GUI to operate on the image at a specific stage or with disabled tool,
* you'll have to specify if you want the tweaked version for the current special mode, or the untweaked one.
* @param dst is the location where the image processing parameters are copied (it is assumed that the memory is allocated by the caller)
* @param tweaked is used to choose between the tweaked ProcParams (if there is one) or the untweaked one */
virtual void getParams (procparams::ProcParams* dst, bool tweaked=false) = 0;
/** An essential member function. Call this when a setting has been changed. This function returns a pointer to the
* processing parameters, that you have to update to reflect the changed situation. When ready, call the paramsUpdateReady
* function to start the image update.
* @param change is the ID of the changed setting */
virtual procparams::ProcParams* beginUpdateParams () = 0;
/** An essential member function. This indicates that you are ready with the update of the processing parameters you got
* with the beginUpdateParams call, so the image can be updated. This function returns immediately.
* The image update starts immediately in the background. If it is ready, the result is passed to a PreviewImageListener
* and to a DetailedCropListener (if enabled). */
virtual void endUpdateParams (ProcEvent change) = 0;
void endUpdateParams(ProcEventCode change) { endUpdateParams(ProcEvent(change)); }
virtual void endUpdateParams (int changeFlags) = 0;
// Starts a minimal update
virtual void startProcessing (int changeCode) = 0;
/** Stops image processing. When it returns, the image processing is already stopped. */
virtual void stopProcessing () = 0;
/** Sets the scale of the preview image. The larger the number is, the faster the image updates are (typical values are 4-5).
* @param scale is the scale of the preview image */
virtual void setPreviewScale (int scale) = 0;
/** Returns the scale of the preview image.
* @return the current scale of the preview image */
virtual int getPreviewScale () = 0;
/** Returns the full width of the resulting image (in 1:1 scale).
* @return the width of the final image */
virtual int getFullWidth () = 0;
/** Returns the full height of the resulting image (in 1:1 scale).
* @return the height of the final image */
virtual int getFullHeight () = 0;
/** Returns the width of the preview image.
* @return the width of the preview image */
virtual int getPreviewWidth () = 0;
/** Returns the height of the preview image.
* @return the height of the preview image */
virtual int getPreviewHeight () = 0;
virtual bool getHighQualComputed() = 0;
virtual void setHighQualComputed() = 0;
virtual bool updateTryLock() = 0;
virtual void updateUnLock() = 0;
virtual void setLocallabMaskVisibility(bool previewDeltaE, int locallColorMask, int locallColorMaskinv, int locallExpMask, int locallExpMaskinv, int locallSHMask, int locallSHMaskinv, int locallvibMask, int locallsoftMask, int locallblMask, int localltmMask, int locallretiMask, int locallsharMask, int localllcMask, int locallcbMask, int localllogMask, int locall_Mask, int locallcieMask) = 0;
/** Creates and returns a Crop instance that acts as a window on the image
* @param editDataProvider pointer to the EditDataProvider that communicates with the EditSubscriber
* @return a pointer to the Crop object that handles the image data trough its own pipeline */
virtual DetailedCrop* createCrop (::EditDataProvider *editDataProvider, bool isDetailWindow) = 0;
virtual bool getAutoWB (double& temp, double& green, double equal, StandardObserver observer, double tempBias) = 0;
virtual void getCamWB (double& temp, double& green, StandardObserver observer) = 0;
virtual void getSpotWB (int x, int y, int rectSize, double& temp, double& green) = 0;
virtual bool getFilmNegativeSpot(int x, int y, int spotSize, procparams::FilmNegativeParams::RGB &refInput, procparams::FilmNegativeParams::RGB &refOutput) = 0;
virtual void getAutoCrop (double ratio, int &x, int &y, int &w, int &h) = 0;
virtual void saveInputICCReference (const Glib::ustring& fname, bool apply_wb) = 0;
virtual void setProgressListener (ProgressListener* l) = 0;
virtual void setSizeListener (SizeListener* l) = 0;
virtual void delSizeListener (SizeListener* l) = 0;
virtual void setAutoExpListener (AutoExpListener* l) = 0;
virtual void setHistogramListener (HistogramListener *l) = 0;
virtual void setPreviewImageListener (PreviewImageListener* l) = 0;
virtual void setAutoCamListener (AutoCamListener* l) = 0;
virtual void setAutoBlackListener (AutoBlackListener* l) = 0;
virtual void setAutoBlackxListener (AutoBlackxListener* l) = 0;
virtual void setFlatFieldAutoClipListener (FlatFieldAutoClipListener* l) = 0;
virtual void setFrameCountListener (FrameCountListener* l) = 0;
virtual void setBayerAutoContrastListener (AutoContrastListener* l) = 0;
virtual void setXtransAutoContrastListener (AutoContrastListener* l) = 0;
virtual void setpdSharpenAutoContrastListener (AutoContrastListener* l) = 0;
virtual void setpdSharpenAutoRadiusListener (AutoRadiusListener* l) = 0;
virtual void setAutoBWListener (AutoBWListener* l) = 0;
virtual void setAutoWBListener (AutoWBListener* l) = 0;
virtual void setAutoColorTonListener (AutoColorTonListener* l) = 0;
virtual void setAutoprimListener (AutoprimListener* l) = 0;
virtual void setAutoChromaListener (AutoChromaListener* l) = 0;
virtual void setRetinexListener (RetinexListener* l) = 0;
virtual void setWaveletListener (WaveletListener* l) = 0;
virtual void setImageTypeListener (ImageTypeListener* l) = 0;
virtual void setLocallabListener (LocallabListener* l) = 0;
virtual void setFilmNegListener (FilmNegListener* l) = 0;
virtual void setMonitorProfile (const Glib::ustring& monitorProfile, RenderingIntent intent) = 0;
virtual void getMonitorProfile (Glib::ustring& monitorProfile, RenderingIntent& intent) const = 0;
virtual void setSoftProofing (bool softProof, bool gamutCheck) = 0;
virtual void getSoftProofing (bool &softProof, bool &gamutCheck) = 0;
virtual ProcEvent setSharpMask (bool sharpMask) = 0;
virtual ~StagedImageProcessor () {}
/** Returns a staged, cached image processing manager supporting partial updates
* @param initialImage is a loaded and pre-processed initial image
* @return the staged image processing manager */
static StagedImageProcessor* create (InitialImage* initialImage);
static void destroy (StagedImageProcessor* sip);
};
/**
* @brief Initializes the RT engine
* @param s is a struct of basic settings
* @param baseDir base directory of RT's installation dir
* @param userSettingsDir RT's base directory in the user's settings dir
* @param loadAll if false, don't load the various dependencies (profiles, HALDClut files, ...), they'll be loaded from disk each time they'll be used (launching time improvement) */
int init (const Settings* s, const Glib::ustring& baseDir, const Glib::ustring& userSettingsDir, bool loadAll = true);
/** Cleanup the RT engine (static variables) */
void cleanup ();
/** This class holds all the necessary information to accomplish the full processing of the image */
class ProcessingJob
{
public:
virtual ~ProcessingJob() {}
/** Creates a processing job from a file name. This function always succeeds. It only stores the data into the ProcessingJob class, it does not load
* the image thus it returns immediately.
* @param fname the name of the file
* @param isRaw shall be true if it is a raw file
* @param pparams is a struct containing the processing parameters
* @return an object containing the data above. It can be passed to the functions that do the actual image processing. */
static ProcessingJob* create (const Glib::ustring& fname, bool isRaw, const procparams::ProcParams& pparams, bool fast = false);
/** Creates a processing job from a file name. This function always succeeds. It only stores the data into the ProcessingJob class, it does not load
* the image thus it returns immediately. This function increases the reference count of the initialImage. If you decide not the process the image you
* have to cancel it by calling the member function void cancel(). If the image is processed the reference count of initialImage is decreased automatically, thus the ProcessingJob
* instance gets invalid. You can not use a ProcessingJob instance to process an image twice.
* @param initialImage is a loaded and pre-processed initial image
* @param pparams is a struct containing the processing parameters
* @return an object containing the data above. It can be passed to the functions that do the actual image processing. */
static ProcessingJob* create (InitialImage* initialImage, const procparams::ProcParams& pparams, bool fast = false);
/** Cancels and destroys a processing job. The reference count of the corresponding initialImage (if any) is decreased. After the call of this function the ProcessingJob instance
* gets invalid, you must not use it any more. Don't call this function while the job is being processed.
* @param job is the job to destroy */
static void destroy (ProcessingJob* job);
virtual bool fastPipeline() const = 0;
};
/** This function performs all the image processing steps corresponding to the given ProcessingJob. It returns when it is ready, so it can be slow.
* The ProcessingJob passed becomes invalid, you can not use it any more.
* @param job the ProcessingJob to cancel.
* @param errorCode is the error code if an error occurred (e.g. the input image could not be loaded etc.)
* @param pl is an optional ProgressListener if you want to keep track of the progress
* @return the resulting image, with the output profile applied, exif and iptc data set. You have to save it or you can access the pixel data directly. */
IImagefloat* processImage (ProcessingJob* job, int& errorCode, ProgressListener* pl = nullptr, bool flush = false);
/** This class is used to control the batch processing. The class implementing this interface will be called when the full processing of an
* image is ready and the next job to process is needed. */
class BatchProcessingListener : public ProgressListener
{
public:
/** This function is called when an image gets ready during the batch processing. It has to return with the next job, or with NULL if
* there is no jobs left.
* @param img is the result of the last ProcessingJob
* @return the next ProcessingJob to process */
virtual ProcessingJob* imageReady(IImagefloat* img) = 0;
};
/** This function performs all the image processing steps corresponding to the given ProcessingJob. It runs in the background, thus it returns immediately,
* When it finishes, it calls the BatchProcessingListener with the resulting image and asks for the next job. It the listener gives a new job, it goes on
* with processing. If no new job is given, it finishes.
* The ProcessingJob passed becomes invalid, you can not use it any more.
* @param job the ProcessingJob to cancel.
* @param bpl is the BatchProcessingListener that is called when the image is ready or the next job is needed. It also acts as a ProgressListener.
**/
void startBatchProcessing (ProcessingJob* job, BatchProcessingListener* bpl);
extern MyMutex* lcmsMutex;
}