Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This set of labs introduces the student to the use of image processing algorithms. The goal of these labs is to familairize yourself with the

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
This set of labs introduces the student to the use of image processing algorithms. The goal of these labs is to familairize yourself with the Raspberry PI camera, image capture, and image processing and to use simple image processing algorithms within the C++ coding environment. 4.1 Task 1 Use the onboard camera to capture a raw black and white (or grayscale or RGB) image of either student's face. Write a C ++ program to process the image and reduce the resolution to a 4848 pixel approximation. Then display the approximation to the screen using black and white solid characters. This resolution reduction is a well-known process called adjacent-averaging method. You should use file I/O to accomplish this task and classes to contain and manipulate the image data. Also, you should use the vector class to hold the image data. 4.1.1 Getting the Image Due to the extensive library of Python installed within Raspbian, we will use Python to capture and initially process the image from the robot camera such that the result is a relatively small file size grayscale jpeg file. In your subdirectory, edit a file called image-capture.py using nano and write the Once you save this file (ensure the extension on the file is .py) then you can run it using the following statement from the terminal. python3 image_capture.py imagefilename. jpg where "imagefilename" is the name that you choose for the image. The Python code will save the initial image to that filename and also will generate a grayscale roduced file size version called "imagefilenameBW.jpg" that you will use to complete task 1 in this second project. If you want to look at the image you will need to transfer the file to the PC so that an image viewer can be used. The application "scp" from the PC console can be used to accomplish this (refer to Chapter 1 for details). The image file saved is a single channel jpeg file. To simplify the reading of this type of file, two library (header) files provide some helpful functions. The header files are stb_image.h stb_image_write.h These header files can be found on the D2L site for the course. One can also find them at the following github link: (https://github.comothings/stb). Copy them to your subdirectory within the Raspberry PI Zero W and then use the stbi_load() function. Here is an example: To use the vector class for the processed image data (i.e. after reducing the resolution) one could use the following: \#include vector my_new_image; my_new_image. reserve (width*height); 4.1.3 Sobel Edge Detection There are a number of common image processing algorithms which reveal specific features of images. One such algorithm reveals outlines of objects within an image for the purpose of detection or enhancement. This is the Sobel Edge Detection algorithm. The way it works is to find small groups of pixels within an image and apply a local constant mask which emphasizes differences in pixel intensity along x-and y-directions. Effectively, this reveals strong gradients which indicate "edges" in the image. The masks are applied through element-by-element multiplication with small groups of image pixels and then the resulting small group results are summed. The application overlaps the small pixel groups by moving the masks from left to right one pixel at a time. The masks are represented by two 3 -by-3 matrices: one in the x-direction (Gx) and one in the y-direction (Gy). Note: This algorithm is intended to work with grayscale images. Gx=121000121,Gy=101202101=GxT Applying the masks can be done in C++ through embedded loops similar to the pseudo-code below, // starting image is called In_image which is assumed a nxm image // In image (i,j) is the pixel intensity at the ith-row and j th-column // In image (i:i+2,j:j+2) is the 33 sub block of the image with upper If left corner ith-row and jth-column for i=1:n2 for j=1:m2 Gxsum = sum (GxIn_image(i:i+2,j:j+2));// element-wise matrix mult Gysun = sum (GyIimage(i:1+2,j:j+2));/ element-vise matrix mult Out_image (i+1,j+1)=sqrt( Gxsum*Gxsum + Gysum*Gysum ); end end Note: The resulting image should be an array of float or double type values. Then the resulting image is an (n2)(m2) sized float or double valued image which can be thresholded as a binary (or black and white) image to identify the edges. Use the onboard camera to capture a raw image of one or more objects. Write a C+ program to process the image and apply a Sobel Edge Detection algorithm for edge detection. Then write a new image file with the results of the edge detection algorithm, average the image to a 4848 size, and print a representation of the result to the screen by using thresholding and printing cither solid or empty characters similar to what was accomplished in Task 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What is the average transaction amount for Montana (MT)?

Answered: 1 week ago