MCPcopy Create free account
hub / github.com/ActiveState/code / marksimilar

Function marksimilar

recipes/Python/576689_Copymove_forgery/recipe-576689.py:185–209  ·  view source on GitHub ↗

Draw discovered similar image regions.

(image, clust, size)

Source from the content-addressed store, hash-verified

183 return clusters
184
185def marksimilar(image, clust, size):
186 """
187 Draw discovered similar image regions.
188 """
189 global opt
190 blocks = []
191 if clust:
192 draw = ImageDraw.Draw(image)
193 mask = Image.new('RGB', (size,size), 'cyan')
194 for cl in clust:
195 for x,y in cl:
196 im = image.crop((x,y,x+size,y+size))
197 im = Image.blend(im,mask,0.5)
198 blocks.append((x,y,im))
199 for bl in blocks:
200 x,y,im = bl
201 image.paste(im,(x,y,x+size,y+size))
202 if int(opt.imauto):
203 for cl in clust:
204 cx1 = min([cx for cx,cy in cl])
205 cy1 = min([cy for cx,cy in cl])
206 cx2 = max([cx for cx,cy in cl]) + block_len
207 cy2 = max([cy for cx,cy in cl]) + block_len
208 draw.rectangle([cx1,cy1,cx2,cy2],outline="magenta")
209 return image
210
211if __name__ == '__main__':
212 cmd = OptionParser("usage: %prog image_file [options]")

Callers 1

recipe-576689.pyFile · 0.85

Calls 7

minFunction · 0.85
blendMethod · 0.80
maxFunction · 0.50
DrawMethod · 0.45
newMethod · 0.45
appendMethod · 0.45
pasteMethod · 0.45

Tested by

no test coverage detected