[libcamera-devel] qcam: saveImageAs: Set image quality explicitly

Message ID 20200318151336.11829-1-kieran.bingham@ideasonboard.com
State Accepted
Commit 92c7b1cc1d04f460512d6bd00e8cda1dd3697648
Headers show
Series
  • [libcamera-devel] qcam: saveImageAs: Set image quality explicitly
Related show

Commit Message

Kieran Bingham March 18, 2020, 3:13 p.m. UTC
The QImageWriter defines a method to set the output image quality.
Explicitly set it to 95 to override any defaults.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/qcam/main_window.cpp | 1 +
 1 file changed, 1 insertion(+)

Comments

Laurent Pinchart March 18, 2020, 3:41 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Wed, Mar 18, 2020 at 03:13:36PM +0000, Kieran Bingham wrote:
> The QImageWriter defines a method to set the output image quality.
> Explicitly set it to 95 to override any defaults.

You could add, although it's a Qt implementation detail, that by default
the JPEG image handler uses a quality of 75, which isn't considered high
enough ?

> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/qcam/main_window.cpp | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index ae1760dfd647..1869fdfc8679 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -360,6 +360,7 @@ void MainWindow::saveImageAs()
>  		return;
>  
>  	QImageWriter writer(filename);
> +	writer.setQuality(95);
>  	writer.write(image);
>  }
>
Kieran Bingham March 19, 2020, 12:32 p.m. UTC | #2
Hi Laurent,

On 18/03/2020 15:41, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Wed, Mar 18, 2020 at 03:13:36PM +0000, Kieran Bingham wrote:
>> The QImageWriter defines a method to set the output image quality.
>> Explicitly set it to 95 to override any defaults.
> 
> You could add, although it's a Qt implementation detail, that by default
> the JPEG image handler uses a quality of 75, which isn't considered high
> enough ?


Indeed, some element of 'ringing' has been observed in the output
images, so I have increased the quality level.

Thank you for determining the default setting, I hadn't identified what
the QT5 default was. I assumed I could get Qt to tell me, but the
.quality() method returns -1 for me :-(


I can update the commit message to:

"
The QImageWriter defaults to an image quality value of 75 which can lead
to perceivable visual artefacts.

Improve the quality of the output by explicitly setting the image
quality to 95.
"


>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>> ---
>>  src/qcam/main_window.cpp | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
>> index ae1760dfd647..1869fdfc8679 100644
>> --- a/src/qcam/main_window.cpp
>> +++ b/src/qcam/main_window.cpp
>> @@ -360,6 +360,7 @@ void MainWindow::saveImageAs()
>>  		return;
>>  
>>  	QImageWriter writer(filename);
>> +	writer.setQuality(95);
>>  	writer.write(image);
>>  }
>>  
>
Laurent Pinchart March 19, 2020, 1:11 p.m. UTC | #3
Hi Kieran,

On Thu, Mar 19, 2020 at 12:32:38PM +0000, Kieran Bingham wrote:
> On 18/03/2020 15:41, Laurent Pinchart wrote:
> > On Wed, Mar 18, 2020 at 03:13:36PM +0000, Kieran Bingham wrote:
> >> The QImageWriter defines a method to set the output image quality.
> >> Explicitly set it to 95 to override any defaults.
> > 
> > You could add, although it's a Qt implementation detail, that by default
> > the JPEG image handler uses a quality of 75, which isn't considered high
> > enough ?
> 
> Indeed, some element of 'ringing' has been observed in the output
> images, so I have increased the quality level.
> 
> Thank you for determining the default setting, I hadn't identified what
> the QT5 default was. I assumed I could get Qt to tell me, but the
> .quality() method returns -1 for me :-(
> 
> I can update the commit message to:
> 
> "
> The QImageWriter defaults to an image quality value of 75 which can lead
> to perceivable visual artefacts.
> 
> Improve the quality of the output by explicitly setting the image
> quality to 95.
> "

Works for me.

> >> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> >> ---
> >>  src/qcam/main_window.cpp | 1 +
> >>  1 file changed, 1 insertion(+)
> >>
> >> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> >> index ae1760dfd647..1869fdfc8679 100644
> >> --- a/src/qcam/main_window.cpp
> >> +++ b/src/qcam/main_window.cpp
> >> @@ -360,6 +360,7 @@ void MainWindow::saveImageAs()
> >>  		return;
> >>  
> >>  	QImageWriter writer(filename);
> >> +	writer.setQuality(95);
> >>  	writer.write(image);
> >>  }
> >>

Patch

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index ae1760dfd647..1869fdfc8679 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -360,6 +360,7 @@  void MainWindow::saveImageAs()
 		return;
 
 	QImageWriter writer(filename);
+	writer.setQuality(95);
 	writer.write(image);
 }