Advertisement
Guest User

AnalyzeScreenshot

a guest
Apr 20th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. % Image analysis Part 1
  2. function [board] = AnalyzeScreenshotFunction()
  3. clc; clear;
  4. % Read in image file
  5. pixels = imread('Screenshot_Alpha.png');
  6. [height, width, colors] = size(pixels);
  7.  
  8. % Initilize empty board
  9. board = zeros(4, 4);
  10.  
  11. binaryIm = false(height, width);
  12.  
  13. % Read through pixels
  14. for row = 1:1:height
  15. for col = 1:1:width
  16. r = pixels(row, col, 1);
  17. g = pixels(row, col, 2);
  18. b = pixels(row, col, 3);
  19. value = GetTileColor(r, g, b);
  20. if (value > -1)
  21. binaryIm(row, col) = 1;
  22. end
  23. end
  24. end
  25. %imshow(pixels);
  26. imshow(binaryIm);
  27. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement