Skip to content

Add grayscale image filter#47

Open
maehw wants to merge 1 commit intoxtech:masterfrom
maehw:grayscale-filter
Open

Add grayscale image filter#47
maehw wants to merge 1 commit intoxtech:masterfrom
maehw:grayscale-filter

Conversation

@maehw
Copy link
Collaborator

@maehw maehw commented Mar 9, 2025

This is a preparation to work on templates + filters (see also: #40).

I have implemented a simple grayscale filter which should assist debugging problems that arise when combining templates with filters because the basic filter does some adjustments, but imo they are not clearly visible/ distinguishable from not having applied a filter.

Also fixed usage output in src/main_filter.cpp (because you cannot define the output directory, it's hard-coded) and added some other debug outputs. Nice to have this tiny little tool to test filtering!

This may not add large benefit to self-o-mat, but I think it may assist debugging. And at least some people may want to use grayscale images... 😄

Biggest benefit is to "demo" what parts of the code need to be changed (which was not 100% intuitive). We may add this to the wiki:

  • Add C++ header + implementation file under src/logic/filters/; new class must derive from interface IImageFilter
  • To test the new filter, modify src/main_filter.cpp: add include for the new header file, add an instance to the vecotr by adding a call to filters.push_back(); build the tool and test your filter 😉
  • In src/logic/ImageProcessor.h: add header include, enum value to FILTER, and filter name to vector filterNames; add instance of the new filter as member variable (compare basicFilter + grayscaleFilter)
  • In src/logic/ImageProcessor.cpp: add case for new FILTER enum value and add a call to method processImage(image, gain) of the member instance there
  • Add new files to the add_executable() sections of CMakeLists.txt
  • Finally, add mapping of numeric value to FILTER enum value inside of BoothLogic::getFilter(); otherwise new filter will be presented on the web UI for selection but the actual runtime choice will fall back to NO_FILTER; this was a small, unexpected pitfall for me

Happy to get feedback on this, but no rush.

Cheers

@ClemensElflein
Copy link
Member

Looks good to me, in order to make this easier to implement in the future, we could assign each filter an ID string instead of an int. Then we could send those to the frontend (by querying the filter vector), the frontend sends the selected ID back and the filter selection is stored by ID instead of index. This way, we should not need to have a separate enum.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments