Question

% BACKGROUND:Image processing is the generation of a new image from one or more existing images....

% BACKGROUND:Image processing is the generation of a new image from one or more existing images. % MATLAB makes it easy to work with images by providing some basic functions % that allow you to read and write images in standard image -file formats, such as JPEG % Locate the attached photo of a blue bird stored in JPEG format, bbird.jpg (must be on same folder as script). % Fill in the ? in the code with correct values to change the color of the % bird from blue to red. clear close all clc % Reads the image from the file into an array named bbird bbird = imread('bbird.jpg'); % Displays the image image(bbird) % Forces display to have corrected aspect ratio axis equal % Forces the display to omit empty white areas above, below, left, or right of the image. axis tight % Dimensions of array-note the 3 dimensions [rows, cols, rgb] = size(bbird); % To look at individual values within the array, we need three indices, for example: % bbird (236,361,1) % bbird (236,361,2) % bbird (236,361,3) % These three numbers give the values of the red component, the green component, % and the blue component of the color of the pixel at location 236, 361 % (row 236 from the top, column 361 from the left). % A pixel is one square piece of a mosaic of colors that make up a digital image, in this % case a 525-by-775 image, and every pixel consists of three numbers, representing % the intensities of red, green, and blue light that together create the % color of the pixel in the human eye. Each of these numbers falls in the range 0 % to 255, with higher values meaning higher intensity % Suppose we wanted a red bird. We can do a little image processing to % change the blue bird into a red bird. All it takes is a nested for-loop: % Copies all the pixels of bbird into rbird. rbird = bbird; % The nested for-loop allows us to inspect each pixel to see whether it is % blue enough to be part of the bluebirds blue feathers. tic % timing the image processing using for-loop for row = ? for col = ? % The if-statement determines how blue a pixel is. % If the blue channel is more than 20% larger than the mean of the three color channels: if ? > 1.2 * mean(?)) % it sets the red channels value in redbirds pixel to be equal to the blue channel of bluebirds pixel?; % It then sets the green and blue channels in redbirds pixel to zero, so that % there is no hint of green or blue?; end end end

0 0
Add a comment Improve this question Transcribed image text
Answer #1

% BACKGROUND:Image processing is the generation of a new image from one or
% more existing images
%MATLAB makes it easy to work with images by providing some basic functions
% that allow you to read and write images in standard image -file formats, such as JPEG
% Locate the attached photo of a blue bird stored in JPEG format, bbird.jpg (must be on same folder as script).
% Fill in the ? in the code with correct values to change the color of the % bird from blue to red.
clear
close all
clc
% Reads the image from the file into an array named bbird
bbird = imread('bbird.jpg');

% Displays the image
image(bbird) ;

% Forces display to have corrected aspect ratio
axis equal ;

% Forces the display to omit empty white areas above, below, left, or right of the image.
axis tight ;

% Dimensions of array-note the 3 dimensions
[rows, cols, rgb] = size(bbird);

% To look at individual values within the array, we need three indices, for example:
% bbird (236,361,1)
% bbird (236,361,2)
% bbird (236,361,3)
% These three numbers give the values of the red component, the green component,
% and the blue component of the color of the pixel at location 236, 361
% (row 236 from the top, column 361 from the left).
% A pixel is one square piece of a mosaic of colors that make up a digital image, in this
% case a 525-by-775 image, and every pixel consists of three numbers, representing
% the intensities of red, green, and blue light that together create the
% color of the pixel in the human eye. Each of these numbers falls in the range 0
% to 255, with higher values meaning higher intensity
% Suppose we wanted a red bird. We can do a little image processing to
% change the blue bird into a red bird. All it takes is a nested for-loop:
% Copies all the pixels of bbird into rbird.
rbird = bbird;

% The nested for-loop allows us to inspect each pixel to see whether it is
% blue enough to be part of the bluebirds blue feathers.
tic % timing the image processing using for-loop
for row = 1:rows
for col =1:cols
% The if-statement determines how blue a pixel is.
% If the blue channel is more than 20% larger than the mean of the three color channels:
if rbird(row,col,3) > 1.2 * mean(rbird(row,col,:))
% it sets the red channels value in redbirds pixel to be equal to the blue channel of bluebirds pixel?
rbird(row,col,1) = bbird(row,col,3);
% It then sets the green and blue channels in redbirds pixel to zero, so that
% there is no hint of green or blue?;
rbird(row,col,2) = 0;
rbird(row,col,3) = 0;
end
end
end

Add a comment
Know the answer?
Add Answer to:
% BACKGROUND:Image processing is the generation of a new image from one or more existing images....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #PYTHON# In this exercise you will write code which loads a collection of images (which are...

    #PYTHON# In this exercise you will write code which loads a collection of images (which are all the same size), computes a pixelwise average of the images, and displays the resulting average. The images below give some examples that were generated by averaging "100 unique commemorative photographs culled from the internet" by Jason Salavon. Your program will do something similar. Write a function in the cell below that loads in one of the sets of images and computes their average....

  • The ACME Manufacturing Company has hired you to help automate their production assembly line. Cameras have...

    The ACME Manufacturing Company has hired you to help automate their production assembly line. Cameras have been placed above a conveyer belt to enables parts on the belt to be photographed and analyzed. You are to augment the system that has been put in place by writing C code to detect the number of parts on the belt, and the positions of each object. The process by which you will do this is called Connected Component Labeling (CCL). These positions...

  • 4. Write a function extract(pixels, rmin, rmax, cmin, cmax) that takes the 2-D list pixels contai...

    Please design the function in version 3 of python 4. Write a function extract(pixels, rmin, rmax, cmin, cmax) that takes the 2-D list pixels containing pixels for an image, and that creates and returns a new 2-D list that represents the portion of the original image that is specified by the other four parameters. The extracted portion of the image should consist of the pixels that fall in the intersection of the rows of pixels that begin with row rmin...

  • use MATLAB to upload the following: an image that you want to process (can be taken...

    use MATLAB to upload the following: an image that you want to process (can be taken yourself or downloaded from the internet) a script that processes the image in TWO ways. manipulates the colors averages pixels together Please make sure the script displays the images (like how I did with the 40 and 80 pixel averaging) so I can easily compare them to the original. Make sure to COMMENT your code as well. Homework 13 Please upload the following: an...

  • Python Project

    AssignmentBitmap files map three 8-bit (1-byte) color channels per pixel. A pixel is a light-emitting "dot" on your screen. Whenever you buy a new monitor, you will see the pixel configuration by its width and height, such as 1920 x 1080 (1080p) or 3840x2160 (4K). This tells us that we have 1080 rows (height), and each row has 1920 (width) pixels.The bitmap file format is fairly straight forward where we tell the file what our width and height are. When...

  • from PIL import Image import random # NOTE: Feel free to add in any constant values...

    from PIL import Image import random # NOTE: Feel free to add in any constant values you find useful to use BLACK = (0, 0, 0) WHITE = (255, 255, 255) # NOTE: Feel free to add in any helper functions to organize your code but # do NOT rename any existing functions (or else, autograder # won't be able to find them!!) # NOTE: The following function is already completed for you as an example # You can use...

  • Your program should be capable of creating a ppm image of the flag of Benin • The new flag gener...

    Your program should be capable of creating a ppm image of the flag of Benin • The new flag generated should use the proper width-to-height ratio as defined on Wikipedia for the flag. o For the colors, use pure red, and yellow, and a value of 170 for green. ▪ Pure color values are talked about in Lab 6. o The left green field should be 6/15ths of the width of the flag. Variables country_code should also include a new...

  • in java Original: Sound Visualization Write a program that uses StdAudio and Picture to create an...

    in java Original: Sound Visualization Write a program that uses StdAudio and Picture to create an interesting two-dimensional color visualization of a sound file while it is playing. Be creative! Additional Notes: double[] data = StdAudio.read(<filename>); -> Takes a sound file and store it as a 2D array of real numbers. Picture pic = new Picture(300,200); -> Creates a picture 300 pixels wide and 200 pixels high Color c= new Color(<red>,<green>,<blue>); -> Each value of <red>, <green>, <blue> is between...

  • Hi. I require your wonderful help with figuring out this challenging code. import java.awt.Color; import java.awt.image.BufferedImage;...

    Hi. I require your wonderful help with figuring out this challenging code. import java.awt.Color; import java.awt.image.BufferedImage; import java.io.*; import javax.imageio.ImageIO; public class ImageLab { /* * This is the grayscale example. Use it for inspiration / help, but you dont * need to change it. * * Creates and returns a new BufferedImage of the same size as the input * image. The new image is the grayscale version of the input (red, green, and * blue components averaged together)....

  • Mountain Paths (Part 1) Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e...

    Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT