a) What was the input image for your robot loaded into MATLAB?Include the original image you gave MATLAB, or the picture the Webcam took), explain how you load it.
The original image was a heart.Its loaded by the im-read funciton that reads the iage files and sotres all the pixels in the image in a matrix. To display the image, I can use the imshow to see the orgiincal aimge..
b) how are the traces extracted from the image. Explain and include an image/screenshot for converting to grayscale, binarizing it, performing morphological operations (img 4 and img 5 from Task 6)
The traces needed to draw the image at the very end are done by the following:
Converted to grayscale and all colour is removed.
Image is binarized
2 morphological operations are applied so the image is cleaned up and eroded to leave only the thin line traces.
img4 = bwmorph(img3,'clean');
img5 = bwmorph(img4,'thin',inf);
c) How are pixels extracted in order from the thin-line image? Discuss how the math principle of recursion plays a role, and insert a screenshot of the scatter plot of the extracted pixels generated by MATLAB
Linear ordering of pixels happens through a recursive function to create the ordered pixels. Recursion is required because it allows MATLAB to go in one direction along the edge and collect the whole boundary. It fucntiosnas if it formed a connected line around the obect which is very useful for when the robot is drawing the heart.
d) Explain how the coordinates are broken into segments that make up different pixel traces of the image. Include the MATLAB plot of the Traces.
The list of coordinates that were collected from the previous steps are split into distinct segments using coords2segments which idenitfies where one path ends and another begins. This allows each segemented part to be identified, giving it a different colour when plotted.
e) From the image in part d where there any connected segments you could merge as one continuous trace? Explain how the connectSegment function works and include a Matlab image of the updated traces your robot will draw
The connectsegment function checks for endpoints that are close to eachother and joined them create a longer trace. It recudec the number of seperates paths and lines the robot needs to take. The left side of the heart had points that were connected using this function. The plot on the right shows fewer segemtns vsisble compared tot eh plot from d).
f) How did you calculate the minimum and maximum pixel values for the processed image, and how does you code scale the pixel values to meter coordinates to be drawn on the board?
The minimum and maximum pixel values are calculated from the coordinates by finding the smallest and largest values in the x and y directions. To scale the pixel values to metres, a scaling factor is applied and converts the pixel coordinated to meter coordinates so the robot can draw them on the board properly.
g) Briefly explain the benefits of encapsulating all your code into an imageToPixelSegments.
The imagetoPixelsegments makes the code more efficient as it allows me to call a single function instead of rewriting each step to process the drawing.
h) Explain the drawImageFromPix function and the inputs it takes to draw the image.
This function takes the pixel segments and limits and uses them to align the image onto the board, helping guide the robot through each trace and recreate the image with precision.