28 #include <vigra/impex.hxx>
29 #include <wx/busyinfo.h>
30 #include <wx/stdpaths.h>
38 template <
class PixelType>
39 vigra::BasicImage<vigra::RGBValue<PixelType>>
CreateBrightVersion(
const vigra::BasicImage<vigra::RGBValue<PixelType>>& input,
const double correction)
45 std::vector<PixelType> outLut;
48 invResponse.
setOutput(1.0 /
std::pow(2.0, srcImage.getExposureValue() - correction), outLut, 1);
50 vigra::BasicImage<vigra::RGBValue<PixelType>> output(input.size());
58 wxXmlResource::Get()->LoadDialog(
this, parent,
"enfuse_create_file");
61 m_levelChoice = XRCCTRL(*
this,
"create_bright_choice_levels", wxChoice);
63 m_exposuresListBox->InsertColumn(0, _(
"Exposure value (Eev)"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE_USEHEADER);
65 m_previewBitmap = XRCCTRL(*
this,
"create_bright_preview", wxStaticBitmap);
90 vigra::ImageImportInfo
info(filenameString.c_str());
91 const std::string pixeltype(
info.getPixelType());
92 if (!(pixeltype ==
"UINT8" || pixeltype ==
"UINT16"))
94 errorMsg = _(
"The creation of brighter and darker images works only for 8 and 16 bit images.");
99 ImageCache::getInstance().softFlush();
100 m_image = ImageCache::getInstance().getImage(filenameString);
102 catch (std::exception& e)
105 errorMsg = wxString::Format(_(
"Could not load image %s"), filename.c_str());;
106 errorMsg.Append(
" (");
107 errorMsg.Append(e.what());
108 errorMsg.Append(
")");
111 SetLabel(GetLabel() +
" " + filename);
127 wxWindowDisabler disableAll;
128 wxBusyCursor busyCursor;
129 wxGauge* progress = XRCCTRL(*
this,
"enfuse_create_file_progress", wxGauge);
137 wxFileName tempfile(wxFileName::CreateTempFileName(tempDir +
"htb"));
143 progress->SetValue(progress->GetValue() + 1);
156 wxMessageBox(_(
"You have not yet selected at least one exposure correction."), _(
"Hugin toolbox"), wxOK | wxICON_WARNING);
165 const int nrLevels = (
m_levelChoice->GetSelection() + 1) * 2 + 1;
166 double exposure = -std::trunc(nrLevels / 2.0) * stepWidth;
169 for (
int i = 0; i < nrLevels; ++i)
175 exposure = exposure + stepWidth;
182 long index =
m_exposuresListBox->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
234 const long imageWidth =
m_image->image16->size().area() > 0 ?
m_image->image16->width() :
m_image->image8->width();
235 const long imageHeight =
m_image->image16->size().area() > 0 ?
m_image->image16->height() :
m_image->image8->height();
236 const double scaleFactor = std::min<double>((double)previewSize.GetWidth() / imageWidth, (double)previewSize.GetHeight() / imageHeight);
237 m_scaledImg.resize(scaleFactor * imageWidth, scaleFactor * imageHeight);
254 wxImage resizedImage;
255 resizedImage.SetData((
unsigned char*)img.data(), img.width(), img.height(),
true);
257 if (!
m_image->iccProfile->empty() || wxGetApp().GetToolboxFrame()->HasMonitorProfile())
263 wxMemoryDC dc(bitmap);
264 dc.SetBackground(wxBrush(
m_previewBitmap->GetParent()->GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
267 offset.x = (bitmap.GetWidth() - resizedImage.GetWidth()) / 2;
268 offset.y = (bitmap.GetHeight() - resizedImage.GetHeight()) / 2;
269 dc.DrawBitmap(resizedImage, offset);
277 info.setFileType(
"TIFF");
278 if (
m_image->image16->size().area() > 0)
284 if (
m_image->mask->size().area() > 0)
305 if (
m_image->mask->size().area() > 0)
320 const wxFileName exePath(wxStandardPaths::Get().GetExecutablePath());
324 exiftoolCmd.Append(
"-ExposureTime<${exposuretime#;$_*=" + wxString::FromCDouble(
std::pow(2, correction)) +
"} ");
326 wxExecute(exiftoolCmd, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE | wxEXEC_NODISABLE | wxEXEC_MAKE_GROUP_LEADER);
void transformImageSpatial(SrcImageIterator src_upperleft, SrcImageIterator src_lowerright, SrcAccessor sa, DestImageIterator dest_upperleft, DestAccessor da, Functor const &f, vigra::Diff2D ul)
const wxString GetConfigTempDir(const wxConfigBase *config)
return the temp dir from the preferences, ensure that it ends with path separator ...
wxChoice * m_stepWidthChoice
bool CreateAndSaveExposureCorrectedImage(const wxString &filename, const double correction)
create the exposure corrected image and save it to the file
wxBitmap m_scaledwxBitmap
current image as wxBitmap
std::vector< double > m_exposures
void enforceMonotonicity(LUT &lut)
enforce monotonicity of an array (mostly used for lookup tables)
CreateBrightImgDlg(wxWindow *parent)
Constructor, read from xrc ressource; restore position.
void OnSize(wxSizeEvent &e)
handler called when size of control was changed
void exportImageAlpha(ImageIterator image_upper_left, ImageIterator image_lower_right, ImageAccessor image_accessor, AlphaIterator alpha_upper_left, AlphaAccessor alpha_accessor, const ImageExportInfo &export_info)
Write the image and its alpha channel to a file.
vigra::pair< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImage(const ROIImage< Image, Mask > &img)
void GetMonitorProfile(wxString &profileName, cmsHPROFILE &profile)
basic classes and function for queuing commands in wxWidgets
~CreateBrightImgDlg()
destructor, save position
bool SetImage(const wxString &filename, wxString &errorMsg)
load the image, return true on success, otherwise false, error cause is in errorMsg ...
wxStaticBitmap * m_previewBitmap
void OnCreateExposureLevels(wxCommandEvent &e)
update listbox with new exposure values
void RescaleImage()
create rescaled image
wxListCtrl * m_exposuresListBox
void OnExposureChecked(wxListEvent &e)
prevent checking of exposure value 0
void CorrectImage(wxImage &image, const vigra::ImageImportInfo::ICCProfile &iccProfile, const cmsHPROFILE &monitorProfile)
apply color correction to given image using input iccProfile and monitor profile
float pow(float a, double b)
Definition of dialog class to create brighter/darker versions of the image.
void OnExposureSelected(wxListEvent &e)
one exposure selected
vigra::BasicImage< vigra::RGBValue< PixelType > > CreateBrightVersion(const vigra::BasicImage< vigra::RGBValue< PixelType >> &input, const double correction)
creates a brighter or darker version of the input image using HuginBase::Photometric::InvResponse ...
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
vigra::BRGBImage m_scaledImg
current image as vigra::RGBImage
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
ImageCache::EntryPtr m_image
image cache entry for current image
void createEMoRLUT(const std::vector< float > ¶ms, VECTOR &lut)
void CreatewxBitmap(const vigra::BRGBImage &img)
create the wxBitmap version and apply color profiles
double GetExposureStepWidth() const
returns the current selected exposure step width
str wxEscapeFilename(const str &arg)
special escaping routine for CommandQueues
void setSize(vigra::Size2D val)
Set the image size in pixels.
vigra::triple< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImageRange(ROIImage< Image, Alpha > &img)
static void info(const char *fmt,...)
void OnOk(wxCommandEvent &e)
process all images
All variables of a source image.
long GetCheckedItemCount()
return the number of checked exposures
wxString GetExternalProgram(wxConfigBase *config, const wxString &bindir, const wxString &name)
return path and name of external program, which can be overwritten by the user
wxArrayString m_tempFiles
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
wxArrayString GetTempFiles() const