Question: 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

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!