Question: Please debug this matlab script file Unfortunately this scripts has BUGS!! 8 Here is what it SHOULD display if reading image logo.jpg and entering row
Unfortunately this scripts has BUGS!! 8 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% Note that debugging is often easier if you try running your code over a % much smaller data set, so try using the test.jpg image available on cecil s as it only has 3 rows and 4 columns. You should be able to calculate the expected results for test.jpg by hand and then use the debugger to step through the code and see whether it is doing what you expect or not. % Author : Mr Blu Ray clear % 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): 8 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 (1, rowNumber, 2); b imageData(i, rowNumber, 1): if PixellsBlue (x.g.b) count- count 1i end end bluePercent count/cols 100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
