mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Add a new image filter: Normalize -- to improve the contrast in images
This commit is contained in:
parent
dd9e27fdf7
commit
c99232091f
@ -21,7 +21,7 @@ from calibre.gui2.dnd import (
|
|||||||
IMAGE_EXTENSIONS, dnd_has_extension, dnd_has_image, dnd_get_image, DownloadDialog)
|
IMAGE_EXTENSIONS, dnd_has_extension, dnd_has_image, dnd_get_image, DownloadDialog)
|
||||||
from calibre.gui2.tweak_book import capitalize
|
from calibre.gui2.tweak_book import capitalize
|
||||||
from calibre.utils.imghdr import identify
|
from calibre.utils.imghdr import identify
|
||||||
from calibre.utils.img import remove_borders, gaussian_sharpen, gaussian_blur, image_to_data, despeckle
|
from calibre.utils.img import remove_borders, gaussian_sharpen, gaussian_blur, image_to_data, despeckle, normalize
|
||||||
|
|
||||||
def painter(func):
|
def painter(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
@ -149,6 +149,13 @@ class Despeckle(Command):
|
|||||||
def __call__(self, canvas):
|
def __call__(self, canvas):
|
||||||
return despeckle(canvas.current_image)
|
return despeckle(canvas.current_image)
|
||||||
|
|
||||||
|
class Normalize(Command):
|
||||||
|
|
||||||
|
TEXT = _('Normalize image')
|
||||||
|
|
||||||
|
def __call__(self, canvas):
|
||||||
|
return normalize(canvas.current_image)
|
||||||
|
|
||||||
class Replace(Command):
|
class Replace(Command):
|
||||||
|
|
||||||
''' Replace the current image with another image. If there is a selection,
|
''' Replace the current image with another image. If there is a selection,
|
||||||
@ -368,6 +375,11 @@ class Canvas(QWidget):
|
|||||||
self.undo_stack.push(Despeckle(self))
|
self.undo_stack.push(Despeckle(self))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@imageop
|
||||||
|
def normalize_image(self):
|
||||||
|
self.undo_stack.push(Normalize(self))
|
||||||
|
return True
|
||||||
|
|
||||||
# The selection rectangle {{{
|
# The selection rectangle {{{
|
||||||
@property
|
@property
|
||||||
def dc_size(self):
|
def dc_size(self):
|
||||||
|
@ -273,6 +273,7 @@ class Editor(QMainWindow):
|
|||||||
m.addAction(_('Sharpen image'), self.sharpen_image)
|
m.addAction(_('Sharpen image'), self.sharpen_image)
|
||||||
m.addAction(_('Blur image'), self.blur_image)
|
m.addAction(_('Blur image'), self.blur_image)
|
||||||
m.addAction(_('De-speckle image'), self.canvas.despeckle_image)
|
m.addAction(_('De-speckle image'), self.canvas.despeckle_image)
|
||||||
|
m.addAction(_('Improve contrast (normalize image)'), self.canvas.normalize_image)
|
||||||
|
|
||||||
self.info_bar = b = self.addToolBar(_('Image information bar'))
|
self.info_bar = b = self.addToolBar(_('Image information bar'))
|
||||||
b.setObjectName('image_info_bar')
|
b.setObjectName('image_info_bar')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user