Week 3 - Image Processing Research


Image Processing Research

For this week, I research some basic image processing of what we need for our project. Which I imagine we need to intake an image as black and white (maybe) and output/create some game objects.

From there, I began to research how to achieve this effect. I first searched for some related image processing methods, including the website mentioned by the professor in class last week. That website is: https://www.kodeco.com/479-using-streaming-assets-in-unity

Then I learned that the more commonly used methods are color thresholding and edge detection to process the received images. After that, the required Game Objects can be generated by collecting image data.

After researching, I also tried color matching and color thresholding methods in Unity and successfully obtained a similar effect.

Below is the process of implementing this, hoping to be helpful for our upcoming project.

Implement Explanation

1. First, I drew three images in the paint software on my computer and a drawing with pen and paper to use as experimental objects.



2. Created two game objects (prefab) respectively in black and white in Unity.
3. Script
  • First, I am getting all the pixel colors and dimensions from the image. Also, calculate the starting point of where the game objects should start to instantiate.


  • Then, start to loop through all the pixels to generate all the spawn points and save them to an array.

  • Finally, loop through all the spawn points we just save and instantiate corresponding game objects. Right at this moment I am still using color matching which I check if the pixel is black or white.

  • Note: I received a bug from this part and took me a while to fix it which is the image I pushed to the script does not have read/write permission. And thus, is not giving any output to me. From there I change the read/write permission and also change the Texture Type to Sprite to prevent any weird shape output.

  • Optimization: I was able to successfully output the image I draw from what I did, but as I try to use some image that I draw with pen and paper, it is not working, which I notice since the pen and paper is not as black and white as it identifies in Unity. So I change part of the script so I could compare the pixel to a color threshold instead of matching the color.
Outputs




Comments