ImageFromTextGenerator icon indicating copy to clipboard operation
ImageFromTextGenerator copied to clipboard

A very good text generation enhancement framework

Open monkeycc opened this issue 1 year ago • 4 comments

A very good text generation enhancement framework

Shortcomings were discovered during use

  1. There is no way to control the spacing between each text
  2. Noise integration enhancement, some integrations may result in incomplete display of certain fonts
  3. Background_comors and background_imagepaths cannot be set simultaneously. For example, I want to randomly generate different background colors and image backgrounds

Hope to increase more effects such as:

  1. Relief
  2. Contrast ratio
  3. Text Transparency
  4. ImageTransform

monkeycc avatar Jan 14 '25 08:01 monkeycc

Thank you for using and testing IFTG.

Can you provide examples and screenshots of the issues you are facing for the first and second ones? For the third one, you can use the BatchesImagesGenerator class, which allows you to set the background colors and image paths simultaneously, but there is currently no support for randomization.

Thank you also for suggesting effects. We will add them as soon as possible.

OmarSamirz avatar Jan 14 '25 10:01 OmarSamirz

image

  1. There is no way to control the spacing between each text Some fonts are too close in distance

image image image 2. Noise integration enhancement, some integrations may result in incomplete display of certain fonts

    [BlurNoise()], 
    [BrightnessNoise()], 
    [DilateNoise()], 
    [ElasticNoise()],
    [ErodeNoise()],
    [GaussianNoise()], 
    [PixelDropoutNoise()], 

This problem will not occur with a single execution

    [DilateNoise(), BrightnessNoise()],
    [DilateNoise(),ShadowNoise()],
    [BrightnessNoise(), PixelDropoutNoise()],

Similar issues may arise after integration

# 增强类列表,每个类代表一种图像处理中的增强或变换效果
noise_classes = [
    BlurNoise,         # 模糊增强:对图像进行模糊处理,模拟失焦或运动模糊效果
    BrightnessNoise,   # 亮度增强:调整图像的亮度,模拟光照变化
    DilateNoise,       # 膨胀增强:对图像进行膨胀操作,使图像中的亮区域扩展
    ElasticNoise,      # 弹性增强:模拟弹性形变效果,使图像产生扭曲变形
    ErodeNoise,        # 腐蚀增强:对图像进行腐蚀操作,使图像中的亮区域收缩
#     FlipNoise,         # 翻转增强:对图像进行水平或垂直翻转(已注释掉)
    GaussianNoise,     # 高斯增强:向图像添加高斯分布的随机噪声
    PixelDropoutNoise, # 像素丢弃增强:随机丢弃图像中的部分像素,模拟数据丢失
    RotationNoise,     # 旋转增强:对图像进行随机角度的旋转
    ShadowNoise,       # 阴影增强:向图像添加阴影效果,模拟光照遮挡
]

# 生成所有可能的增强组合
all_noises = []
for r in range(1, len(noise_classes) + 1):  # 从1到所有增强的数量
    combinations = itertools.combinations(noise_classes, r)  # 生成组合
    for combo in combinations:
        all_noises.append([cls() for cls in combo])  # 实例化增强对象并添加到列表

# ...
results = BatchesImagesGenerator(noises=[random.choice(all_noises)])

Sort all combinations once, easy to identify problems

monkeycc avatar Jan 14 '25 11:01 monkeycc

We will add character spacing functionality soon. Each noise class includes parameters that can be configured to adjust the intensity of the noise. You can also use a randomized version of each noise class to set a range of noise intensity and take advantage of randomization.

OmarSamirz avatar Jan 14 '25 12:01 OmarSamirz

@monkeycc can you give me a screenshot example of Relief and contrast ratio noises?

We have added text transparency and for ImageTransform you can find an equivalent class called ImageNoiseAdder and DirectoryNoiseAdder

OmarSamirz avatar Jan 17 '25 15:01 OmarSamirz