Advertisement
makispaiktis

Image Processing Onramp - Course 4 - Identifying text finding patterns

Aug 1st, 2023
1,160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.59 KB | None | 0 0
  1. % 1. Read, grayscale, adjust, binarize
  2. I = imread("IMG_006.jpg");
  3. gs = im2gray(I);
  4. gsAdj = imadjust(gs);
  5. BW = imbinarize(gsAdj,"adaptive","ForegroundPolarity","dark");
  6. imshowpair(I,BW,"montage")
  7.  
  8. I2 = imread("IMG_005.jpg");
  9. gs2 = im2gray(I2);
  10. gs2Adj = imadjust(gs2);
  11. BW2 = imbinarize(gs2Adj);
  12. imshowpair(I2,BW2,"montage")
  13.  
  14. % 2. Sum of rows to understand if this image is a receipt
  15. S = sum(BW, 2);
  16. plot(S);
  17. S2 = sum(BW2, 2);
  18. plot(S2);
  19.  
  20. % 3. Further practice
  21. I = imread("IMG_018.jpg");
  22. gs = im2gray(I);
  23. gsAdj = imadjust(gs);
  24. BW = imbinarize(gsAdj);
  25. S = sum(BW, 2);
  26. plot(S);
  27. imshow(BW);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement