Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Matlab. Do not download and use any existing MATLAB ditherfunction. The goal of this is to implement the ditheralgorithm. 1) You need to implement the

Matlab. Do not download and use any existing MATLAB ditherfunction. The goal of this is to implement the ditheralgorithm.

1) You need to implement the ordered dithering algorithms.2) You must use your implemented algorithms for all 50 images togenerate 50 dithered output images. 3) Create an animated gif file with your 50 dithered imagesusing ditherGI F.m

Step1: Implement the ordered dithering algorithm for 50 gray -scale images ( i.e., frame_ * _delay - 0.1s .gif ). Check Chapter3slide for the pseudo code. Because the original images are based on8bit color, you have to convert each color im age to a gray - scale(8bit gray) image (simply use rgb2gray() ). You have to use thefollowing 4x4 dither matrix for your algorithm

image

Step2: For imp lementation of th e ordered di thering , you haveto create a function (in orderedDither.m) like: ditheredImg =orderedDither(sourceImg); Step 2: Apply the ordered ditheringalgorithm for given 50 images, and generate 50 dithered outputimages. Your dithered images should be binary (black or white)images. You should not type 50 image files names manually. You codeshould generate a file name string with sprintf , read each inputimage/frame , apply the dithering algorithm for each image, andfinally save an output image in gif (see ditherGIF.m) .

Step 3 : Lastly, create a single animated gif file by compilingyour 50 dithered output images created from Step 2 . You can use aMATLAB code to create an animated gif ( see ditherGIF .m ) You mustset the delay for each frame to 1 0/100 second (0.1 second)

% script ditherGIF.m% sews them into a gif% %apply dither to each of 50 imagesfor i = 1:50    fileName = sprintf("homework1_animation_frames/frame_%d_delay-0.1s.gif", i);        %read image and convert from byte indexed to rgb    %Frames to read, specified as the comma-separated pair consisting of 'Frames'     %and a positive integer, a vector of integers, or 'all'.     %For example, if you specify the value 3, imread reads the third frame in the file.     %If you specify 'all', then imread reads all frames and returns them in the order in which they appear in the file.        [indexedSrcImg, colorMap] = imread(fileName, "Frames", 1);    sourceImg = ind2rgb(indexedSrcImg, colorMap);        %apply dither to image--in HW1 you must implement this function and include orderedDither.m.     ditheredImg = orderedDither(sourceImg);        %stitch image into the gif    %format image into byte indexed image    [indexedImg, colorMap] = rgb2ind(ditheredImg,256);        %write indexed image to its own file    writeName = sprintf("homework1_dithered_frames/frame_%d_delay-0.1s.gif", i);    imwrite(indexedImg, colorMap, writeName, 'gif');        %write indexed image to the gif    if i == 1      imwrite(indexedImg, colorMap, 'homework1_dithered_frames/dithered_animation.gif', 'gif', 'DelayTime',0.1, 'Loopcount', inf);    else      imwrite(indexedImg, colorMap, 'homework1_dithered_frames/dithered_animation.gif', 'gif', 'DelayTime',0.1, 'WriteMode', 'append');    endend

16 X 2 107 12 4 14 6 3 11 19 15 7 13 5

Step by Step Solution

3.56 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

The steps to implement the ordered dithering algorithm in MATLAB are as follows Implement the ordere... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seeing Through Statistics

Authors: Jessica M.Utts

4th Edition

1285050886, 978-1305176249, 1305176243, 978-1305322394, 978-1285050881

More Books

Students also viewed these Programming questions