Filter löschen
Filter löschen

How do I lower an image quality?

39 Ansichten (letzte 30 Tage)
Sebastián López Rendón
I'm new to matlab and need to create a for loop that gradually lowers the quality of an image in a GUI. I tried searching on the internet but can't find how to do it. I'm aware it's probably imwrite but I can't get it to work properly.
The image is .jpeg format, I just need to know how to lower it once and I'll figure everything else from there.
  1 Kommentar
Mann Baidi
Mann Baidi am 2 Mai 2024
What do you mean by 'lower an image quality'?
Does it means changing the resloution of the image or degrade the quality by adding some noise in it?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Harsh
Harsh am 2 Mai 2024
Hi,
It seems like you are interested in learning how to modify the resolution of an image and compress an image using MATLAB. Here are simplified steps for doing both:
1. To change the resolution of an image:
Use the imresize function. This function allows you to adjust the image's size to a new resolution.
image = imread("SampleImage.jpeg");
lowResImage = imresize(image, 0.5);
2. To compress an image:
Use the wcompress function. This function is designed for image compression.
As an example on image compression using wcompress, you can open the "Image Compression Using Basic Parameters" example in MATLAB with the following command:
openExample('wavelet/ImageCompressionUsingBasicParametersExample')
Refer to the following links to gather more information about the "imresize" and "wcompress".
  1. https://www.mathworks.com/help/matlab/ref/imresize.html
  2. https://www.mathworks.com/help/wavelet/ref/wcompress.html
I hope this helps, thanks!

Weitere Antworten (2)

John D'Errico
John D'Errico am 2 Mai 2024
Bearbeitet: John D'Errico am 2 Mai 2024
There are other ways to lower image quality. Several ideas have already been mentioned.
  1. Resize the image, then expand it back up again to the original size. Effectively, that adds in artifacts due to the interpolation needed to resize the image.
  2. Compress the image, then decompress it. And image compression can be done in a lossless way, but if more compression is done, then you will incur image artifacts due to the compression.
  3. Apply noise to the image. The amount of noise will influence the degree of quality loss.
  4. Apply a blur of some sort. This might be a motion blur. It might be a general gaussian smear.
Each of these image degradations will have characteristics of their own. I'm sure we could think of a few more ways to achieve a quality degradation, as image quality has many facets. You will first need to decide what source of quality loss seems appropriate to you.
  2 Kommentare
Image Analyst
Image Analyst am 2 Mai 2024
Just look at the tons of filters that you can apply in Adobe Photoshop. For example, turn the image into a painting or stained glass window or pixelize it. Each of them changes the image in some way and that could be interpreted as lowering the quality of the image as compared to the original.
DGM
DGM am 2 Mai 2024
It could be as simple as a change of contrast obscuring key features. Without defined goals, it's as bad as words like "enhance".

Melden Sie sich an, um zu kommentieren.


Sarthak
Sarthak am 2 Mai 2024
Hi Sebastian,
As you suggested, you can indeed use imwrite to reduce the quality of an image using the 'Quality' argument. For more information on how to use it, please refer to the link below:
You can create your 'for' loop iterating over quality with your desired step size and use the following line of code in your 'for' loop for gradually lowering the quality of the image.
imwrite(originalImage, outputFileName, 'Quality', quality);
Hope this helps!
  1 Kommentar
DGM
DGM am 2 Mai 2024
Bearbeitet: DGM am 2 Mai 2024
  • That only applies to JPEG outputs.
  • That's a very specific definition of "quality".
  • The resultant (and change in) "quality" depends significantly on the source image.
  • This can only reduce the quality of the image, even for a 100% quality setting.
All standard JPEG files written by MATLAB are 4:2:0 chroma subsampled. They're all degraded images.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by