Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Students also viewed these Databases questions