Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to speed this up? Tile matching
#1
description of what i am trying to do

So I have a script right now it's doing this
loop through source image for each tile, copy and paste as pattern (difference mode) over top of tile image.
loop through each tile of a visible copy and look at r,g,b using 
make selection of the tile.
Code:
r, _, _, _, _, _ = pdb.gimp_histogram(comp_layer,HISTOGRAM_RED,0,255)
g, _, _, _, _, _ = pdb.gimp_histogram(comp_layer,HISTOGRAM_GREEN,0,255)
b, _, _, _, _, _ = pdb.gimp_histogram(comp_layer,HISTOGRAM_BLUE,0,255)
look at r+g+b value and pick the tile with lowest sum consider that the best match....
and then compose an image using those best match tiles...
what's taking along time right now is this process of selecting the tile and using gimp_histogram...

Is there anyway i could possibly speed this up?
I can't think of one.
Reply
#2
If you do Filter>Blur>Pixellize you get tiles where the R, G, B channels are the average for the tile (so the same as the values you get from the histogram calls). If you Color>Desaturate that using the "Average" method the gray you obtain is therefore (R+G+B)/3 from which you can obtain R+G+B (if needed) (although it could be better to use the Luminosity, which at that point shouldn't be harder to work with).
Reply
#3
Genius...I'll give it a shot and see if it's faster. Thanks!

After bluring the whole result, and use get pixel to get values instead of histogram.
It runs just over little 50% I am guessing 60% of the time previously so that's a major improvement.

Actually it made huge improvements I took out all the debug and it's now like less than a second a tile instead of 8 seconds...wow.
Reply


Forum Jump: