nanoMFG / GSA-Image

Image analysis tool code repository for the Graphene Synthesis Analysis collaboration
Apache License 2.0
1 stars 1 forks source link

Mask caching for MaskingModification #63

Closed jaschil2 closed 4 years ago

jaschil2 commented 4 years ago

Problem:

Right now the mask for each subclass that uses MaskingModification (i.e. everything in the FilterPattern tool) is updated recursively each time the masked image is re-rendered (or whenever MaskingModification.mask() is called). When there are a bunch of layers, this can slow it down as it has to make boolean comparisons between all preceding arrays.

Solution: To speed it up, the masks from the preceding layers in the linked list can be cached for each individual layer so that each layer only recursively updates once. All other updates would simply used the cached version. The cache would need to know when a preceding layer's mask was changed so that it knows to re-cache.

jaschil2 commented 4 years ago

Caching implemented. Images also only update after brush strokes finish, which greatly improves performance (albeit at the cost of the image not updating live).