Remove old comment about the lazy clamp function

This commit is contained in:
Gabriel Almir
2021-01-11 14:10:04 -03:00
parent 8bcbe0113d
commit 3a5cf20b03
3 changed files with 10 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or
# !!! The drawable can be a mask (grayscale channel), don't restrict to layer.
work_drawable = pdb.gimp_image_get_active_drawable(tempImage)
if not work_drawable:
raise RuntimeError, "Failed get active drawable"
@@ -84,10 +85,12 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or
# crop the temp image to size of selection to save memory and for directional healing!!
frisketBounds = grownSelection.mask_bounds
frisketLowerLeftX = frisketBounds[0]
frisketLowerLeftY = frisketBounds[1]
frisketUpperRightX = frisketBounds[2]
frisketUpperRightY = frisketBounds[3]
targetLowerLeftX = targetBounds[0]
targetLowerLeftY = targetBounds[1]
targetUpperRightX = targetBounds[2]
@@ -111,6 +114,7 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or
# X
newWidth, newHeight, newLLX, newLLY = ( targetUpperRightX-targetLowerLeftX, frisketHeight,
targetLowerLeftX, frisketLowerLeftY )
# Restrict crop to image size (condition of gimp_image_crop) eg when off edge of image
newWidth = min(pdb.gimp_image_width(tempImage) - newLLX, newWidth)
newHeight = min(pdb.gimp_image_height(tempImage) - newLLY, newHeight)
@@ -122,13 +126,13 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or
if not orderParam :
useBorder = 1 # User wants NO order, ie random filling
elif orderParam == 1 : # Inward to corpus. 2,3,4
useBorder = directionParam+2 # !!! Offset by 2 to get past the original two boolean values
useBorder = directionParam + 2 # !!! Offset by 2 to get past the original two boolean values
else:
# Outward from image center.
# 5+0=5 outward concentric
# 5+1=6 outward from sides
# 5+2=7 outward above and below
useBorder = directionParam+5
useBorder = directionParam + 5
# Note that the old resynthesizer required an inverted selection !!
@@ -138,6 +142,7 @@ def heal_selection(timg, tdrawable, samplingRadiusParam=50, directionParam=0, or
gimp.displays_flush()
except RuntimeError: # thrown if non-interactive
pass
from time import sleep
sleep(2)

View File

@@ -31,7 +31,6 @@ gettext.install("resynthesizer", gimp.locale_directory, unicode=True)
def heal_transparency(timg, tdrawable, samplingRadiusParam=50, orderParam=2):
# precondition should be enforced by Gimp according to image modes allowed.
if not pdb.gimp_drawable_has_alpha(tdrawable):
pdb.gimp_message("The active layer has no alpha channel to heal.")

View File

@@ -146,6 +146,7 @@ def make_grayscale_map(image, drawable):
original_selection = pdb.gimp_selection_save(image)
pdb.gimp_selection_all(image) # copy requires selection
pdb.gimp_edit_copy(drawable)
if original_selection:
pdb.gimp_selection_load(original_selection) # restore selection in image
pdb.gimp_image_remove_channel(
@@ -199,6 +200,7 @@ def copy_selection_to_image(drawable):
layer_copy = pdb.gimp_image_get_active_layer(image_copy)
# In earlier version, futzed with selection to deal with transparencey
display_debug_image(image_copy)
return image_copy, layer_copy
@@ -227,7 +229,7 @@ def synchronize_contrast(drawable, source_drawable, percent_transfer):
# 2.5 is from experimentation with gimp_brightness_contrast which seems linear in its effect.
contrast_control = (mean - source_mean) * 2.5 * (1 - (percent_transfer / 100))
# clamp to valid range (above formula is lazy, ad hoc)
# clamp to valid range
contrast_control = max(min(contrast_control, 127), -127)
pdb.gimp_brightness_contrast(source_drawable, 0, contrast_control)