Commit f3c93b7e authored by Immanuel Weber's avatar Immanuel Weber
Browse files

add image brightness enhancement support

parent c43ce7db
......@@ -10,6 +10,7 @@ import subprocess
from functools import partial
from collections import defaultdict
from PIL import Image, ImageEnhance
try:
from PyQt5.QtGui import *
......@@ -315,6 +316,8 @@ class MainWindow(QMainWindow, WindowMixin):
self.MANUAL_ZOOM: lambda: 1,
}
enhanceImage = action('Enhance Image', self.enhanceImage, tip='Enhance image for better view')
edit = action('&Edit Label', self.editLabel,
'Ctrl+E', 'edit', u'Modify the label of the selected Box',
enabled=False)
......@@ -406,7 +409,7 @@ class MainWindow(QMainWindow, WindowMixin):
self.tools = self.toolbar('Tools')
self.actions.beginner = (
open, opendir, changeSavedir, openNextImg, openPrevImg, verify, save, save_format, None, create, copy, delete, None,
zoomIn, zoom, zoomOut, fitWindow, fitWidth)
zoomIn, zoom, zoomOut, fitWindow, fitWidth, enhanceImage)
self.actions.advanced = (
open, opendir, changeSavedir, openNextImg, openPrevImg, save, save_format, None,
......@@ -952,6 +955,15 @@ class MainWindow(QMainWindow, WindowMixin):
for item, shape in self.itemsToShapes.items():
item.setCheckState(Qt.Checked if value else Qt.Unchecked)
def enhanceImage(self, value=True):
if not self.image.isNull():
pil_image = Image.fromqimage(self.image)
enhancer = ImageEnhance.Brightness(pil_image)
self.image = enhancer.enhance(2).toqimage()
shapes = self.canvas.shapes
self.canvas.loadPixmap(QPixmap.fromImage(self.image))
self.canvas.loadShapes(shapes)
def loadFile(self, filePath=None):
"""Load the specified file, or the last opened file if None."""
self.resetState()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment