Question: The heatmap function will generate the heatmap image. The function has two parameters: a 3 D matrix representing the RGB image of the dome area

The heatmap function will generate the heatmap image. The function has two parameters: a 3D matrix representing the RGB image of the
dome area and a 2D matrix of radiation values. The function returns the heatmap as a 3D matrix that represents an RGB image.
Review: Working with Images
A 3-dimensional matrix represents images. The rows and columns correspond to the pixels in the image (i.e. the rows and columns).
The third dimension represents the different "channels" of the image (i.e. red-green-blue or hue-saturation-value).
Because we would like to manipulate the color of the image without changing anything else, the HSV image representation (see above) is
quite convenient. Before working with the image, you should first convert it to HSV using the rgb2hsv function.
Once the image is in HSV format, we can consider each channel separately:
Channel 1: "Hue". This channel controls which color is used at each pixel, so we want to set its elements according to the
corresponding values in the radiation matrix. To convert from a radiation level to the appropriate hue value, use the formula below:
Channel 2: "Saturation". This channel controls how strong the color of each pixel is. Set all values in this channel to 1, since we want
the colors in the heatmap to be as vibrant as possible.
Channel 3: "Value". This channel controls how bright are the pixels in the image and thus contains the grayscale picture of the
settlement area. Thus, you should just leave this channel as is.
Once you have made the appropriate changes to the HSV image, convert it back to an RGB image with the hsv2rgb function before
returning from the heatmap function. Function definition and description
The function header and comments are provided for you in the file called heatmap_starter.m. Don't forget to remove
from the
filename before you try to call this function.
function [ img ]= heatmap( img, rad )
% Generates a heatmap image by using values
% from rad to set values in the hue channel for img.
% Hue values vary smoothly depending on the
% corresponding radiation level.
%
img: a 3-dimensional matrix of numbers representing
% an image in RGB (red-green-blue) format, which
% forms the background to which the heatmap
% colors are applied.
% rad: a matrix of numbers representing the radiation
% measurements, between 0 and 100 millisieverts
% It has the same width and height as the img
% parameter.
Testing your heatmap function
To test your heatmap function, first read the dome picture into MATLAB by typing this into the Command Window:
img = imread('dome_area.jpg');
Then get a set of radiation data:
rad =scanradiation (30);
Next, call your removeNoise function and save the smoothed data back into rad:
rad = removeNoise(rad,15); imshow(heatmap(img, rad));
If your removeNoise function and
functions are working correctly, you should see a picture that looks like this:
This test case is also available in the
file. You can add test cases to this file to continue testing your
function.
You can also quickly test your functions using different radiation scans by typing this into the Command Window:
imshow(heatmap(img, removeNoise(scan_radiation(100),15)));
Which should result in this picture:
This method of testing the functions is exactly the same as the step-by-step method outlined above, it just puts all of the steps into one
statement. Use whichever method is the most helpful to you!
The heatmap function will generate the heatmap

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 Programming Questions!