A=imread("inpic.jpg");
B=floor(double(A)/64)*85;
imwrite("outpic.jpg",B(:,:,1),B(:,:,2),B(:,:,3))


2. Convert an image to one with only 27 colours using the following Octave command:
A=imread("girl.jpg"); #for colour set {42, 128, 214}
B=floor(double(A)/86)*86+42;
imwrite("girl27.jpg",B(:,:,1),B(:,:,2),B(:,:,3))

The images ares completely washed out (white).
Using the colour set {0, 128, 255}, there are two methods.
Method 1
A=imread("girl.jpg");
B=floor((A+64)/128)*128;
imwrite("girl27.jpg",B(:,:,1),B(:,:,2),B(:,:,3))

Result - Washed out images.
Method 2
A=imread("girl.jpg");
B=floor(A/85)*128;
imwrite("girl27.jpg",B(:,:,1),B(:,:,2),B(:,:,3))


Result - Much better.
3. Turn the images to greyscale images.
A=imread("girl.jpg");
B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
imwrite("girlgrey.jpg",B)


4. Convert images to greyscale with only 64 intensity values.
A=imread("girl.jpg");
B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
C=floor(double(B)/4)*4;
imwrite("girlgrey64.jpg",C)
Here are the two images. As you can see, very faint and difficult to see.


5. Convert images to greyscale with 16 intensity values.
A=imread("girl.jpg");
B=(A(:,:,1)+A(:,:,2)+A(:,:,3))/3;
C=floor(double(B)/16)*16;
imwrite("girlgrey16.jpg",C)
Here are the images.


No comments:
Post a Comment