Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please fix the bug Unfortunately this scripts has BUGS!! % Here is what it SHOULD display if reading image logo.jpg % and entering row 1,

please fix the bug

Unfortunately this scripts has BUGS!!

% Here is what it SHOULD display if reading image logo.jpg

% and entering row 1, 50, 95 and 100 respectively.

%

% Percentage of blue in row 1 is 0%

% Percentage of blue in row 50 is 17.3469%

% Percentage of blue in row 95 is 60.7143%

% Percentage of blue in row 100 is 90.3061%

% ask the user to specify the name of a jpg file

fileName = input('Please enter the name of a jpg file to read in (e.g. logo.jpg):','s');

rowNumber = input('Please enter the row number to scan:');

% Import the image data into an array

imageData = imread(fileName, 'JPG');

% Plot the original image

figure(1)

image(imageData);

axis equal

% determine dimensions of image data

[rows, cols, colours] = size(imageData);

% Check each pixel in the row, one at a time, to see if it is blue.

for i = 1:rows

% extract colour values for current pixel from specfied rowNumber

r = imageData(i, rowNumber, 3);

g = imageData(i, rowNumber, 2);

b = imageData(i, rowNumber, 1);

if PixelIsBlue(r,g,b)

count = count + 1;

end

end

bluePercent = count/cols*100;

disp(['Percentage of blue in row ' num2str(rowNumber) ' is ' num2str(bluePercent) '%']);

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

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions