Decreased image quality in Matlab

Hi, I am trying to find an easy way to manipulate an image so that I can reduce its quality from 8 to 3 bits.

What would be the easiest way to achieve this? Greetings

+3
source share
3 answers

If you want to scale it linearly, simply divide each pixel value by 255/7 (i.e. if the original image is stored in matrix I, let the low-resolution image be J = I / (255/7)).

UPDATED: Due to an error in my scaling constant.

Here is an example:

Results

+4
source

, uint8 MATLAB, 0 255. 3 ( , 0 7), , :

>> data = uint8([0 23 128 200 255]);  % Create some data of type uint8
>> scaledData = data*(7/255)

scaledData =

    0    1    4    5    7

>> class(scaledData)

ans =

uint8

, 0 7, , , - uint8, MATLAB. 0.

, ( ), 8 (, PNG 4- ).

+2

int8 - Matlab. 3 8 int8, .

Toolbox , numerictype :

T = numerictype(s,w)

Cit. Matlab:

T = numerictype (s, w) numerictype : , s w.

+1

Source: https://habr.com/ru/post/1719264/


All Articles