Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

亮度对比度增强功能存在显示问题,已找到问题并修改 #511

Closed
thgpddl opened this issue Jul 9, 2024 · 3 comments
Closed
Labels
bug Something isn't working enhancement New feature or request Fixed Implemented

Comments

@thgpddl
Copy link

thgpddl commented Jul 9, 2024

在“视图”--“亮度对比度”功能中,修改亮度或对比度后,导致图像画面损坏,效果如下图:
image

经过排查,是在“BrightnessContrastDialog”类的“on_new_value”函数中有问题:

    def on_new_value(self, _):
        """On new value event"""
        brightness = self.slider_brightness.value() / 50.0
        contrast = self.slider_contrast.value() / 50.0

        img = self.img
        if brightness != 1:
            img = PIL.ImageEnhance.Brightness(img).enhance(brightness)
        if contrast != 1:
            img = PIL.ImageEnhance.Contrast(img).enhance(contrast)
        # 此处PIL图像为RGBA模式
       
       # 但是在下方使用了RGB模式,导致显示出现问题
        qimage = QImage(
            img.tobytes(), img.width, img.height, QImage.Format_RGB888
        )
        self.callback(qimage)  # qimage已经是处理后的图片

解决办法为将PIL的RGBA模式转为RGB模式即可:

        img = self.img
        if brightness != 1:
            img = PIL.ImageEnhance.Brightness(img).enhance(brightness)
        if contrast != 1:
            img = PIL.ImageEnhance.Contrast(img).enhance(contrast)
        
        img = img.convert("RGB")   #新增颜色模式转换代码
              
        qimage = QImage(
            img.tobytes(), img.width, img.height, QImage.Format_RGB888
        )

现在图像正常:
image

CVHub520 added a commit that referenced this issue Jul 9, 2024
@CVHub520
Copy link
Owner

CVHub520 commented Jul 9, 2024

Hi, @thgpddl:

Thank you very much for reporting the brightness and contrast enhancement display issue 🙏.

The issue has been resolved by converting the image to RGB mode. Additionally, i have made some optimizations including adding a reset button 🔄. Please update to the latest version to see these improvements 🚀.

image

@CVHub520 CVHub520 added bug Something isn't working enhancement New feature or request labels Jul 9, 2024
@thgpddl
Copy link
Author

thgpddl commented Jul 10, 2024

Hi, @thgpddl:

Thank you very much for reporting the brightness and contrast enhancement display issue 🙏.

The issue has been resolved by converting the image to RGB mode. Additionally, i have made some optimizations including adding a reset button 🔄. Please update to the latest version to see these improvements 🚀.

image

感谢您的工作,但是现在遇到了新的问题,当我打开一个图片文件夹后,调整亮度对比度后,通过按键"D"打开下一张图片时程序闪退,并报错如下:

TypeError: BrightnessContrastDialog.on_new_value() takes 1 positional argument but 2 were given
已放弃 (核心已转储)

@thgpddl thgpddl closed this as completed Jul 10, 2024
@thgpddl thgpddl reopened this Jul 10, 2024
CVHub520 added a commit that referenced this issue Jul 10, 2024
…ts and fixed TypeError in on_new_value method (#511)
@CVHub520
Copy link
Owner

Hi, @thgpddl:
Thank you very much for reporting the brightness and contrast enhancement display issue 🙏.
The issue has been resolved by converting the image to RGB mode. Additionally, i have made some optimizations including adding a reset button 🔄. Please update to the latest version to see these improvements 🚀.
image

感谢您的工作,但是现在遇到了新的问题,当我打开一个图片文件夹后,调整亮度对比度后,通过按键"D"打开下一张图片时程序闪退,并报错如下:

TypeError: BrightnessContrastDialog.on_new_value() takes 1 positional argument but 2 were given
已放弃 (核心已转储)

Fixed. Please git pull the latest code and try to adjust the brightness and contrast again. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request Fixed Implemented
Projects
None yet
Development

No branches or pull requests

2 participants