Question: Matlab practice Write a custom MATLAB function named pixelcounter that counts the number of pixels in a user - specified image that have an intensity

Matlab practice
Write a custom MATLAB function named pixelcounter that counts the number of pixels in a user-
specified image that have an intensity exceeding a user-specified threshold value in a user-specified
colour channel. The pixelcounter function has the following three inputs:
img: the image on which the user wishes to apply the pixelcounter function
clr: the colour channel the user is interested in; specified as 1 for red, 2 for green, or 3 for blue
lim: the threshold intensity value in the specified colour channel
And the following three outputs:
num: the number of pixels exceeding the value specified by lim in the colour channel specified
by clr
perc: the percentage of pixels exceeding the value specified by lim in the colour channel
specified by clr(calculated out of the total number of pixels in img)
avg: the average intensity value for all pixels in the colour channel specified by clr
Note:
You may assume that the user will always supply inputs that are valid (there is no need to
account for any invalid inputs e.g. clr being set to 4).
The Learner Template has hints on how to approach writing this function. You may choose to use
these or pursue coding the function however you like, but your solution should feature the use of
if-else statements and for loops.
Use the sample images to test the function (given in the transcript) : 'BrightonBeach.jpeg', ;Barbie.jpeg', 'Cats.jpeg' and 'Dune.jpeg'
Use semicolon (;) to suppress code output
Do not use any clear or clc commands in the script.
 Matlab practice Write a custom MATLAB function named pixelcounter that counts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!