Skip to content

Commit

Permalink
Add scripting, RGB and multi-unsharp mask
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatAttractor committed Feb 15, 2023
1 parent 44888cf commit 1ddd73e
Show file tree
Hide file tree
Showing 123 changed files with 7,237 additions and 1,407 deletions.
25 changes: 25 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Unit/integration test naming

Pattern 1: Preconditions_Scenario_Result
Pattern 2: Scenario_Result
Pattern 3: Scenario

Keep the text short, avoid unnecessary words. Instead of:

`GivenTwoFiles_WhenFilteredByName_ThenMatchingFileListed`

use:

`TwoFiles_FilterByName_MatchingFileListed`

Prefer patterns 2 & 3 if preconditions and result are obvious and same for the whole suite/test group.


# Scripting API naming conventions

Typically script authors will use property setters more often than the getters. Therefore use setter names without a prefix, and prefix getters with `get`, e.g.:
```Lua
s = imppg.new_settings()
s:unsh_mask_sigma(1.5)
sigma = s:get_unsh_mask_sigma()
```
42 changes: 27 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ project("imppg")

cmake_minimum_required(VERSION 2.8)

enable_testing()

include(config.cmake)
include(utils.cmake)
include(FindPkgConfig)
Expand All @@ -33,30 +35,28 @@ add_executable(imppg WIN32
src/main.cpp
src/normalize.cpp
src/num_ctrl.cpp
src/num_formatter.cpp
src/progress_bar.cpp
src/scrollable_dlg.cpp
src/settings.cpp
src/tcrv_edit.cpp
src/tcrv_wnd_settings.cpp
src/wxapp.cpp
)

target_include_directories(imppg PRIVATE src)
target_compile_options(imppg PRIVATE -Wall -Wextra -Wpedantic -Wold-style-cast -Wno-parentheses)

set(IMPPG_SHADERS_DIR ${CMAKE_INSTALL_FULL_DATAROOTDIR}/imppg/shaders)
set(IMPPG_IMAGES_DIR ${CMAKE_INSTALL_FULL_DATAROOTDIR}/imppg/images)
set(IMPPG_VERSION_MAJOR 0)
set(IMPPG_VERSION_MINOR 6)
set(IMPPG_VERSION_SUBMINOR 5)
set(IMPPG_VERSION_MAJOR 1)
set(IMPPG_VERSION_MINOR 9)
set(IMPPG_VERSION_SUBMINOR 0)

target_compile_definitions(imppg PRIVATE
IMPPG_VERSION_MAJOR=${IMPPG_VERSION_MAJOR}
IMPPG_VERSION_MINOR=${IMPPG_VERSION_MINOR}
IMPPG_VERSION_SUBMINOR=${IMPPG_VERSION_SUBMINOR}
)

set_cpp_standard(imppg)
set_compiler_options(imppg)

if(WIN32)
# The RC file includes the application manifest and defines the application icon.
Expand All @@ -78,7 +78,7 @@ if(UNIX AND NOT APPLE)
set(wxWidgets_CONFIG_OPTIONS --toolkit=gtk3)
endif()

set(WX_COMPONENTS "adv aui xml core base")
set(WX_COMPONENTS "adv aui xml core base richtext")
if(USE_OPENGL_BACKEND)
string(APPEND WX_COMPONENTS " gl")
endif()
Expand All @@ -92,18 +92,15 @@ endif()
include(${wxWidgets_USE_FILE})
target_link_libraries(imppg PRIVATE ${wxWidgets_LIBRARIES})

# TODO: move to backend
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

# TODO: move to backend
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-ffast-math GNU_FFAST_MATH_SUPPORTED)

# TODO: move to backend
if(GNU_FFAST_MATH_SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
endif()
Expand All @@ -122,21 +119,30 @@ else()
endif()

if(USE_CFITSIO EQUAL 1)
target_compile_definitions(imppg PRIVATE USE_CFITSIO=1)
pkg_check_modules(CFITSIO cfitsio REQUIRED)
target_include_directories(imppg PRIVATE ${CFITSIO_INCLUDE_DIRS})
target_link_libraries(imppg PRIVATE ${CFITSIO_LIBRARIES})
endif()

if(ENABLE_SCRIPTING EQUAL 1)
target_compile_definitions(imppg PRIVATE ENABLE_SCRIPTING=1)
target_sources(imppg PRIVATE src/script_dialog.cpp)
endif()

add_subdirectory(src/alignment)
add_subdirectory(src/backend)
add_subdirectory(src/math_utils)
add_subdirectory(src/common)
add_subdirectory(src/backend)
add_subdirectory(src/image)
add_subdirectory(src/logging)
add_subdirectory(src/math_utils)
if(ENABLE_SCRIPTING)
add_subdirectory(src/scripting)
endif()

target_link_libraries(imppg PRIVATE alignment common math_utils backend image logging)

if(ENABLE_SCRIPTING EQUAL 1)
target_link_libraries(imppg PRIVATE scripting)
endif()

# Installation -------------------------------------

Expand All @@ -150,6 +156,12 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_FULL_DOCDIR}
)

install(FILES
doc/scripting/api_reference.md
doc/scripting/scripting.md
DESTINATION ${CMAKE_INSTALL_FULL_DOCDIR}/doc/scripting
)

install(FILES
shaders/copy.frag
shaders/divide.frag
Expand Down
90 changes: 53 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ImPPG (Image Post-Processor)
Copyright (C) 2015-2022 Filip Szczerek ([email protected])
Copyright (C) 2015-2023 Filip Szczerek ([email protected])

version 0.6.5 (2022-04-10)
version 1.9.0-beta (2023-02-15)

*This program comes with ABSOLUTELY NO WARRANTY. This is free software, licensed under GNU General Public License v3 or any later version and you are welcome to redistribute it under certain conditions. See the LICENSE file for details.*

Expand All @@ -22,18 +22,19 @@ version 0.6.5 (2022-04-10)
- 7\. Image sequence alignment
- 7\.1\. High-contrast features stabilization (phase correlation)
- 7\.2\. Solar limb stabilization
- 8\. Misc
- 9\. Known problems
- 10\. Downloading
- 11\. Building from source code
- 11\.1\. Building under Linux and similar systems using GNU (or compatible) toolchain
- 11\.1\.1. Building under Ubuntu 18.04
- 11\.1\.2. Packaging
- 11\.1\.3. Building for macOS
- 11\.2\. Building under MS Windows
- 11\.3\. UI language
- 12\. Acknowledgements
- 13\. Change log
- 8\. Scripting
- 9\. Misc
- 10\. Known problems
- 11\. Downloading
- 12\. Building from source code
- 12\.1\. Building under Linux and similar systems using GNU (or compatible) toolchain
- 12\.1\.1. Building under Ubuntu 18.04
- 12\.1\.2. Packaging
- 12\.1\.3. Building for macOS
- 12\.2\. Building under MS Windows
- 12\.3\. UI language
- 13\. Acknowledgements
- 14\. Change log

----------------------------------------

Expand Down Expand Up @@ -88,7 +89,7 @@ Processing back ends can be switched via menu `Settings/Back end`.
----------------------------------------
## 3. Supported image file formats

Accepted input formats: BMP, JPEG, PNG, TIFF (most of bit depths and compression methods), TGA and other via the FreeImage library, FITS. Image is processed in grayscale and saved in one of the following formats: BMP 8-bit; PNG 8-bit; TIFF 8-bit, 16-bit, 32-bit floating-point (no compression or compressed with LZW or ZIP), FITS 8-bit, 16-bit or 32-bit floating-point.
Accepted input formats: BMP, JPEG, PNG, TIFF (most of bit depths and compression methods), TGA and other via the FreeImage library, FITS. Processed image is saved in one of the following formats: BMP 8-bit; PNG 8-bit; TIFF 8-bit, 16-bit, 32-bit floating-point (no compression or compressed with LZW or ZIP), FITS 8-bit, 16-bit or 32-bit floating-point.

Output images produces by the sequence alignment function are saved as uncompressed TIFF with number of channels and bit depth preserved (except 8-bit palettized ones; those are converted to 24-bit RGB). Input FITS files are saved as FITS with bit depth preserved.

Expand Down Expand Up @@ -130,6 +131,8 @@ Access by:

Unsharp masking can be used for final sharpening (independently of L–R deconvolution) or blurring of the image. The *sigma* parameter specifies the Gaussian kernel’s width; the larger the value, the coarser the sharpening or blurring. `Amount` specifies the effect’s strength. Value < 1.0 blurs the image, 1.0 does nothing, value > 1.0 sharpens the image.

More than one unsharp masks can be specified; they will be applied sequentially. E.g., a sharpening one (amount > 1), and then a smaller-sigma blurring one for mild denoising (amount < 1).


#### Adaptive mode

Expand Down Expand Up @@ -202,13 +205,19 @@ Access by:


----------------------------------------
## 8. Misc
## 8. Scripting

All ImPPG's image processing facilities can be invoked from a script written in the [Lua](https://www.lua.org/) programming language. See the [scripting documentation](doc/scripting/scripting.md) for details.


----------------------------------------
## 9. Misc

ImPPG stores certain settings (e.g. the main window’s size and position) in an INI file, whose location is platform-dependent. On recent versions of MS Windows the path is `%HOMEPATH%\AppData\Roaming\imppg.ini`, where `%HOMEPATH%` usually equals `C:\Users\<username>` (but if OneDrive is enabled, the file may be located there). On Linux the path is `~/.imppg`.


----------------------------------------
## 9. Known problems
## 10. Known problems

- Starting with wxWidgets 3.1.5 on Linux, GL Canvas uses EGL by default. If the GLEW library used for building ImPPG is not built with EGL support, the call to `glewInit` will fail. Solution: either use GLEW built with EGL, or build wxWidgets adding `-DwxUSE_GLCANVAS_EGL=OFF` to its CMake invocation.

Expand All @@ -227,23 +236,28 @@ Solution: change the GTK theme to "Raleigh" (e.g. in Fedora use the "GTK+ Appear


----------------------------------------
## 10. Downloading
## 11. Downloading

ImPPG source code and binaries for MS Windows and Ubuntu 18.04 (x86-64) can be downloaded from:
ImPPG source code and binaries for MS Windows and Ubuntu 20.04 (x86-64) can be downloaded from:
https://github.com/GreatAttractor/imppg/releases


----------------------------------------
## 11. Building from source code
## 12. Building from source code

Building from source code requires a C++ compiler toolchain (with C++17 support), CMake, Boost libraries v. 1.57.0 or later (though earlier versions may work) and wxWidgets 3.0 (3.1 under MS Windows). Support for more image formats requires the FreeImage library, version 3.14.0 or newer. Without FreeImage the only supported formats are: BMP 8-, 24- and 32-bit, TIFF mono and RGB, 8 or 16 bits per channel (no compression). FITS support (optional) requires the CFITSIO library. Multithreaded processing requires a compiler supporting OpenMP.

To enable/disable usage of CFITSIO, FreeImage and GPU/OpenGL back end (they are enabled by default), edit the `config.cmake` file.
To enable/disable usage of CFITSIO, FreeImage, GPU/OpenGL back end and scripting (they are enabled by default), edit the `config.cmake` file.

To remove any created CMake configuration, delete `CMakeCache.txt` and the `CMakeFiles` folder.

To run the tests, execute (from the `build` directory):
```bash
$ ctest
```


### 11.1. Building under Linux and similar systems using GNU (or compatible) toolchain
### 12.1. Building under Linux and similar systems using GNU (or compatible) toolchain

*Note: CMake relies on the presence of the `wx-config` tool to detect and configure wxWidgets-related build options. Sometimes this tool can be named differently, e.g. in Fedora 23 with wxGTK3 packages from repository it is `wx-config-3.0`. Older versions of CMake may not accept it. This can be remedied e.g. by creating a symlink:*
```bash
Expand Down Expand Up @@ -281,19 +295,19 @@ $ cat install_manifest.txt | sudo xargs rm

To use a different installation prefix, add `-DCMAKE_INSTALL_PREFIX=<my_dir>` to the initial CMake invocation.

#### 11.1.1. Building under Ubuntu 18.04
#### 12.1.1. Building under Ubuntu 18.04

The following packages are needed for building under Ubuntu 18.04:
```
git cmake build-essential libboost-dev libwxgtk3.0-gtk3-dev libglew-dev pkg-config libccfits-dev libfreeimage-dev
git cmake build-essential libboost-dev libboost-test-dev libwxgtk3.0-gtk3-dev libglew-dev pkg-config libccfits-dev libfreeimage-dev liblua5.3-dev
```

The default GCC version (7.x) is too old. Install and enable GCC 8 (example instructions: `https://linuxize.com/post/how-to-install-gcc-compiler-on-ubuntu-18-04/`). (Do not choose GCC 9, otherwise the built binary will not run on a clean Ubuntu 18.04 due to too old a version of `libstdc++`.)

After building `imppg`, it can be either installed as in section 11.1, or a Debian package can be created and installed with `apt` (see 11.1.2).


#### 11.1.2. Packaging
#### 12.1.2. Packaging

In order to create a binary package, modify appropriately the final statement in `CMakeLists.txt`:
```cmake
Expand All @@ -305,7 +319,7 @@ $ cpack
```
Note that building needs to be performed in an environment corresponding to the selected target system, so that proper shared objects are linked to (“environment” = a full system installation, a Docker image, or similar).

#### 11.1.3. Building for macOS
#### 12.1.3. Building for macOS

*Note: macOS build and support is still work-in-progress*

Expand All @@ -314,12 +328,7 @@ To build ImPPG for macOS you will need Xcode and [Homebrew](https://brew.sh) ins
OpenMP is currently supported with 3rd party LLVM toolchain installed with Homebrew as Apple disabled OpenMP in clang toolchain distributed with Xcode. As of July 2022 the build method was verified on macOS Monterey 12.5 and Xcode 13.4.1.

Install following libraries with Homebrew:
```bash
$ brew update
$ brew install boost cfitsio cmake freeimage glew mesa pkg-config wxwidgets llvm libomp
```

Now follow Linux build steps:
```bashBuilding under
```bash
$ mkdir build
$ cd build
Expand All @@ -335,13 +344,13 @@ CC=/usr/local/opt/llvm/bin/clang CXX=/usr/local/opt/llvm/bin/clang++ LDFLAGS="-L
```

----------------------------------------
### 11.2. Building under MS Windows
### 12.2. Building under MS Windows

The provided `CMakeLists.txt` supports the [MSYS2](http://www.msys2.org/) build environment. With manual configuration, other toolchains can also be used (e.g. MS Visual Studio).

In order to build ImPPG (64-bit) under MSYS2, follow its installation instructions at http://www.msys2.org/. Then open the MSYS2/MinGW64 shell (after default installation: `c:\msys64\mingw64.exe`) and install the ImPPG’s dependencies by running:
```bash
$ pacman -S git mingw-w64-x86_64-cmake base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost mingw-w64-x86_64-cfitsio mingw-w64-x86_64-freeimage mingw64/mingw-w64-x86_64-glew mingw64/mingw-w64-x86_64-wxmsw3.1
$ pacman -S git mingw-w64-x86_64-cmake base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-boost mingw-w64-x86_64-cfitsio mingw-w64-x86_64-freeimage mingw64/mingw-w64-x86_64-glew mingw64/mingw-w64-x86_64-wxmsw3.1 mingw64/mingw-w64-x86_64-lua
```

Download the ImPPG’s source code manually or clone it with Git:
Expand Down Expand Up @@ -371,7 +380,7 @@ To run ImPPG from Windows Explorer, the subfolders `images`, `pl`, `shaders` and


----------------------------------------
### 11.3. UI language
### 12.3. UI language


ImPPG supports multiple user interface languages using the wxWidgets built-in internationalization facilities. All translatable strings in the source code are surrounded by the `_()` macro. Adding a new translation requires the `GNU gettext` package and consists of the following steps:
Expand All @@ -396,14 +405,21 @@ Binary distribution of ImPPG needs only the MO (binary) language files. Beside t


----------------------------------------
## 12. Acknowledgements
## 13. Acknowledgements

Russian and Ukrainian translations: Rusłan Pazenko.
German translation: Marcel Hoffmann.


----------------------------------------
## 13. Change log
## 14. Change log

**1.9.0-beta** (2023-02-15)

- **New features**
- Scripting support
- RGB processing
- Multiple unsharp masks

**0.6.5** (2022-04-10)

Expand Down
Loading

0 comments on commit 1ddd73e

Please sign in to comment.