Question
Matlab programming need help, I don't Matlabhe matlab syntax, but I have included the psedocode and my code . psedocode: function output = halftone(input) img
Matlab programming need help, I don't Matlabhe matlab syntax, but I have included the psedocode and my code .
psedocode:
function output = halftone(input)
img = read image (img_file)
// create 10 dot patterns in 3 dimensional matrix for example dots(:,:,1) = [0,0,0; 0,0,0; 0,0,0];
dots is 3 dimensional matriux should be
// size of dots is = 3, 3, 10
[row, cols] = size (input);
// loop through the input image doing the following;
// computer the average value over 3*3 pixel block.
// use this average value to copy the appropriate dot pattern to the output image.
// if the dimensions of the input iamge are not multiples of three then treat the edges as special cases
// If the dimensions of the input image are not multiples of three then treat the edges as special case:
// if the dimension of the input imnage are not mutiples of three then treat the edges as special cases
// - compute average over whatevr size block is at edge of image (2* 3)
// -use this value to copy poart of the appropriate dot pattern to the output image 2* 3 block for example.
for r = 1:3 rows
for c= 1: 3 cols
compute average over 3 *3 in input image
use linear interpolation to map this average to the integer 0-9
END
copy the appropriate dot pattertn to the output image
end
// special case for column dimentiuon not mutiple of 3
...
end
//special case for tow dimension not multiple of 3.
my code so far:
function output = halftone(in)
% create dot patterns using matrix % dots(:, :, 1) = 0, 0, 0; 0, 0,0; 0,0 ,0;i dots = [3,3,10];
dots(:,:,1) = [0,0,0; 0,0,0; 0,0,0]; dots(:,:,2) = [0,255,0; 0,0,0; 0,0,0]; dots(:,:,3) = [0,255,0; 0,0,0; 0,0,255]; dots(:,:,4) = [255,255,0; 0,0,0; 0,0,255]; dots(:,:,5) = [255,255,0; 0,0,0; 255,0,255]; dots(:,:,6) = [255,255,255; 0,0,0; 255,0,255]; dots(:,:,7) = [255,255,255; 0,0,255; 255,0,255]; dots(:,:,8) = [255,255,255; 0,0,255; 255,255,255]; dots(:,:,9) = [255,255,255; 255,0,255; 255,255,255]; dots(:,:,10) = [255,255,255; 255,255,255; 255,255,255];
[rows, col] = size(in);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started