Page 1 of 1

Practical Exercise 2: Image Colours Learning Outcomes Upon successful completion of this practical task you will be able

Posted: Mon May 02, 2022 11:38 am
by answerhappygod
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 1
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 1 (62.55 KiB) Viewed 26 times
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 2
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 2 (58.8 KiB) Viewed 26 times
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 3
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 3 (56.21 KiB) Viewed 26 times
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 4
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 4 (73.21 KiB) Viewed 26 times
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 5
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 5 (61.95 KiB) Viewed 26 times
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 6
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 6 (55.52 KiB) Viewed 26 times
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 7
Practical Exercise 2 Image Colours Learning Outcomes Upon Successful Completion Of This Practical Task You Will Be Able 7 (81.07 KiB) Viewed 26 times
with the calculations
Practical Exercise 2: Image Colours Learning Outcomes Upon successful completion of this practical task you will be able to: • Apply a problem-solving methodology to create a computer solution that changes the colours in an RGB colour image Become familiar with the structure and flow of conditional and iterative statements in MATLAB. Introduction to the practical Background of colour replacement: In photography and video applications colour replacement is a useful tool. In photography this technique could be used to change a colour in a photograph to another colour, for example changing the colour of a red chocolate wrapper to blue (below). In video applications similar techniques are used to replace a block of colour in a video stream (such as green or blue) to a completely different background or image, this is called chroma- keying or 'green-screening and is how the weather is often performed on the news; the weather presenter is usually standing in front of a green-screen and the green is replaced with a weather map, which is what you see on your television.
The RGB colour-space: To understand how this is possible we need to understand how colour is represented on a computer and in MATLAB). The most common way colour is represented is using what's known as the RGB colour-space (R = red, G = green, B = blue). When looking at an image on a computer screen it will be made up of rectangular light elements called pixels (a portmanteau of 'picture elements), the colour of these pixels will be determined by the ratios of red, green and blue light being emitted by the screen. For example, a pure red pixel would be emitting red light only (red turned on), while the green and blue light would be turned off. Cyan (greeny-blue) would have red light turned off with roughly equal parts green and blue light being emitted. Below are the primary and secondary light colours and their RGB values; 255 represents 100% on, 0 represents completely off. Green Yellow White Black R=0 R=255 R = 255 R=0 G-255 G-255 G 255 oo BO B=0 B0 B-255 Cyan R-O G=255 B=255 Red R-255 loo B=0 Blue R = 0 Magenta oo R = 255 B - 255 G-0 B - 255 Figure 1: Primary and secondary colour wheel and RGB values.
On top of this you also have shades, pixels are not just binary 'on' or 'off' elements but can be dimmed or brightened to emit more or less light to create many different colours and shades, this is shown below for pure red pixels. 250 Figure 2: Pure red pixels. R value is increasing from 0 - 255 from left to right, Gand B values are set to zero throughout Part 1: Designing a colour change program For this prac you'll be designing a program that: a. Prompts a user to specify a colour they want to change in an image, b. Iterates through the image and changes all pixels of that colour to black, and c. Displays the resultant image in a new figure window. The image you will be using is shown in figure 3 and is an image of plastic chips called coloredChips.png. This image is an in-built image in MATLAB available through the Image Processing Toolbox Figure 3: 'colored Chips.png' image.
Task 1 - State the Problem Exercise: Start by writing down the problem statement so the requirements of this task are clear to you, check with your tutor if you are unsure of what you need to be doing. Points to be addressed: The problem statement should be clear and concise, double-check with your tutor if you are not sure of anything written in the problem statement Task 2 - Specify your input and output data Exercise: Using the information given on the previous page determine the input you have/need to solve the problem and what you need to output to accomplish the objective. The image you'll be using for this task is 'coloredChips.png' (in the Image Processing Toolbox) so use MATLAB to import this image into your Workspace if you need so you can give details about the data-type, etc of the file. Use Table I in the appendix of this guide for the syntax for importing images. Points to be addressed: - What data type is the matrix in your Workspace? . What are the dimensions of the matrix shown in the Workspace? Explain what each dimension represents, especially the third dimension which will equal 3. - Use the data cursor on your figure (Tools -> Data Cursor) to get an idea of the RGB values for all the different coloured chips in the image, explain how that will relate to the task you are to complete. Also think about what you will need to output to fulfil this task, (numbers, words, images, graphical output?). Describe this in detail. What assumptions are you making (if any) to help you solve/simplify
Task 3 - Design your Algorithm Exercise: Now think about the algorithm you'll need to use to do this task, write out the logic on paper and turn this into a flow-chart. It may help to use the logic exercise in the box below to work out in your mind how you would logically do this task and how this could then translate to a computer. Logic Task: Use the grid below to work out how you would logically check the colour of each square in the grid then change red squares to black. How would you increment from one square to the next in a row to check each colour? How would you increment each row to check the entire grid? Use the row/column indices (1-13) provided to help with this. Write the step-by-step process in your notes, this will become your algorithm. 1 2 3 4 5 6 7 8 9 10 11 12 13 1 2 3 4 6 7 8 9 10 11 12 13
Points to be addressed: Also think about the logic needed to check for other coloured pixels. I.e. What sort of values might you look for in primary colours (red, green, blue)? What about secondary colours such as cyan, magenta or yellow? E.g. yellow pixels generally have red and green values that are greater than 127 and blue values that are less than 127. Think about the conditional statement structure and the logical expression(s) you'll need to write to check for this. Task 4 - Write, run and test your algorithm in MATLAB Exercise: Now, in a new MATLAB script file write a program that will: - Ask your user what colour they want changed. A text menu type system may help you with this. - Iterates through the image to find all the appropriately coloured pixels and changes them to black. Displays the resultant image to the user. Points to be addressed: . Compare the output image to what you would expect to get from your handworked algorithm in task 3. . If this is not the case, troubleshoot your algorithm/script to find where the mistake is.
Part 2: Create a User-defined function for program For this part of the prac you'll be taking your colour change program and the algorithm you designed in tasks 3 & 4 and will convert this so the search and colour-change part of the algorithm is performed in a user-defined function. Task 5 - Write, run and test your user-defined function Exercise: Now, in a new MATLAB script file write a user-defined function that will perform the search algorithm and the colour-changing: Your main script should continue to contain the part of the program that prompts your user what colour they want changed. Your main script should also continue to handle the displaying of the images Your user-defined function should now take in the image and which colour to change and then perform the search and colour change process. Your user-defined function should also output the processed image back to your main script. Points to be addressed: Compare the output image to what you would expect to get from your handworked algorithm in task 3. Make sure this is still what you expect and troubleshoot your code if it's not. Make sure to present thorough evidence of testing your program with a wide range of inputs in your report. Also, make sure to clearly present your program's output with a discussion on how well it fulfils the requirements of the task in your report (strengths and weaknesses). Lastly, check the report guidelines on Canvas (under the Week 1 Module -> Assessment Task Instructions (IMPORTANT) -> Practical Instructions to make sure you've covered all aspects of the problem solving methodology adequately.