Question

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 image that you want to process (can be taken yourself or downloaded from the int



88 Background information for Image Processing 8% 3-D matrices $ 3-D matrices are no different than the matrices we have used
% Pull out subsets of the matrix (EG rows 3-4, columns 1-3, of sheets 2-3) % For this class, we wont need more than 3 pages.
imshow(int_data) % Zoom in on the image. What happened? Why did this happen? % For the answers to those questions, we need to
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1- Manipulating colours

% Read in original RGB image.

rgbImage = imread('flower.png');

% Extract color channels.

redChannel = rgbImage(:,:,1); % Red channel

greenChannel = rgbImage(:,:,2); % Green channel

blueChannel = rgbImage(:,:,3); % Blue channel

% Create an all black channel.

allBlack = zeros(size(rgbImage, 1), size(rgbImage, 2), 'uint8');

% Create color versions of the individual color channels.

just_red = cat(3, redChannel, allBlack, allBlack);

just_green = cat(3, allBlack, greenChannel, allBlack);

just_blue = cat(3, allBlack, allBlack, blueChannel);

% Recombine the individual color channels to create the original RGB image again.

recombinedRGBImage = cat(3, redChannel, greenChannel, blueChannel);

% Display them all.

subplot(3, 3, 2);

imshow(rgbImage);

fontSize = 20;

title('Original RGB Image', 'FontSize', fontSize)

subplot(3, 3, 4);

imshow(just_red);

title('Red Channel in Red', 'FontSize', fontSize)

subplot(3, 3, 5);

imshow(just_green)

title('Green Channel in Green', 'FontSize', fontSize)

subplot(3, 3, 6);

imshow(just_blue);

title('Blue Channel in Blue', 'FontSize', fontSize)

subplot(3, 3, 8);

imshow(recombinedRGBImage);

title('Recombined to Form Original RGB Image Again', 'FontSize', fontSize)

% Set up figure properties:

% Enlarge figure to full screen.

set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0, 1, 1]);

% Get rid of tool bar and pulldown menus that are along top of figure.

% set(gcf, 'Toolbar', 'none', 'Menu', 'none');

% Give a name to the title bar.

set(gcf, 'Name', 'Demo ', 'NumberTitle', 'Off')

2- Averaging pixels

% Demo code to divide the image up into 16 pixel by 16 pixel blocks

% and replace each pixel in the block by the mean,

% of all the gray levels of the pixels in the block.

%

clc;

clearvars;

close all;

workspace;

fontSize = 16;

% Read in a standard MATLAB gray scale demo image.

folder = fullfile(matlabroot, '\toolbox\images\imdemos');

if ~exist(folder, 'dir')

% If that folder does not exist, don't use a folder

% and hope it can find the image on the search path.

folder = [];

end

baseFileName = 'cameraman.tif';

fullFileName = fullfile(folder, baseFileName);

grayImage = imread(fullFileName);

% Get the dimensions of the image. numberOfColorBands should be = 1.

[rows columns numberOfColorBands] = size(grayImage)

% Display the original gray scale image.

subplot(1, 2, 1);

imshow(grayImage, []);

title('Original Grayscale Image', 'FontSize', fontSize);

% Enlarge figure to full screen.

set(gcf, 'Position', get(0,'Screensize'));

set(gcf,'name','Image Analysis Demo','numbertitle','off')

% Define the function that we will apply to each block.

% First in this demo we will take the median gray value in the block

% and create an equal size block where all pixels have the median value.

% Image will be the same size since we are using ones() and so for each block

% there will be a block of 8 by 8 output pixels.

meanFilterFunction = @(theBlockStructure) mean2(theBlockStructure.data(:));

% Block process the image to replace every pixel in the

% 16 pixel by 16 pixel block by the median of the pixels in the block.

blockSize = [16, 16];

blockyImage = blockproc(single(grayImage), blockSize, meanFilterFunction);

[rows columns] = size(blockyImage);

% Display the block median image.

subplot(1, 2, 2);

imshow(blockyImage, []);

caption = sprintf('Block Mean Image\nInput block size = 16\n%d rows by %d columns', rows, columns);

title(caption, 'FontSize', fontSize);

Add a comment
Know the answer?
Add Answer to:
use MATLAB to upload the following: an image that you want to process (can be taken...
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
  • the picture above is the one you are supposed to use for the MATlab code please...

    the picture above is the one you are supposed to use for the MATlab code please help Problems. Grayscale images are composed of a 2D matrix of light intensities from O (Black) to 255 (White). In this lab you will be using grayscale images and do 2D-array operations along with loops and iflelse branches. 1. We can regard 2D grayscale images as 2D arrays. Now load the provided image of scientists at the Solvay Conference in 1927 using the imread)...

  • Task 2: (2 Marks) Noisy Image Restoration You have been provided with seven images named IMG-5698. JPG to IMG-5704. JPG...

    Task 2: (2 Marks) Noisy Image Restoration You have been provided with seven images named IMG-5698. JPG to IMG-5704. JPG. These images were taken in low light conditions with a very high ISO setting which results in "noise" on the image (random fluctuations in pixel intensity) and "bright pixels" (pixels which appear bright in every image, despite not being hit by light) In addition to the seven source images you are also provided with a "dark frame", dark.png. This is...

  • Image proccessing in PROGRAMING C NO MAIN FUNCTION NEEDED! Color-Filter an image: 1. All pixels in...

    Image proccessing in PROGRAMING C NO MAIN FUNCTION NEEDED! Color-Filter an image: 1. All pixels in the picture with color in the chosen range will be replaced with new color. The following shows the pseudo code for the color filter. if (R in the range of [target_r - threshold, target_r + threshold]) and (G in the range of [target_g - threshold, target_g + threshold]) and (B in the range of [target_b - threshold, target_b + threshold]) R = replace_r ;...

  • 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...

  • 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...

  • Using C++ Language This is your last assignment for this course! It is about 3D vectors...

    Using C++ Language This is your last assignment for this course! It is about 3D vectors and arrays. You can either choose to work with vectors or arrays. You don't need to do both (but, you can!). I am going to describe it using the word array. You can translate it for vectors. The dimensions of the array are 200x600x3. The datatype of the values stored in the array are unsigned char (ranges from 0 to 255). The first dimension...

  • MATLAB ONLY gauss.jpg BELOW Instructions: The following problems can be done interactively or by writing the...

    MATLAB ONLY gauss.jpg BELOW Instructions: The following problems can be done interactively or by writing the commands iın an M-file (or by a combination of the two). In either case, record all MATLAB input commands and output in a text document and edit it according to the instructions of LAB 1 and LAB 2. For problem 2, include a picture of the rank-1 approximation. For problem 3, include a picture of the rank-10 approximation and for problem 4, include a...

  • 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...

  • Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arg...

    Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arguments shall consist of the following 1. The width (in pixels) of the image, as a positive decimal integer 2. The height (in pixels) of the image, as a positive decimal integer 3. The minimum area (in pixels) that a triangle must have in order to be drawn,...

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
ADVERTISEMENT