Advertisement
sajid006

threed

May 12th, 2021
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Wed May 12 13:59:27 2021
  4.  
  5. @author: Sajid
  6. """
  7.  
  8. from skimage.io import imread, imshow
  9. from skimage.filters import gaussian, threshold_otsu
  10. from skimage.feature import canny
  11. from skimage.transform import probabilistic_hough_line, rotate
  12.  
  13. #testing
  14. import numpy as np
  15. import os
  16. import cv2
  17. import math
  18. import matplotlib.pyplot as plt
  19.  
  20. import torch
  21. from torch import nn
  22. from torch import optim
  23. import torch.nn.functional as F
  24. from torchvision import datasets, transforms, models
  25.  
  26.  
  27.  
  28. from collections import OrderedDict
  29. from PIL import Image
  30.  
  31. import pandas as pd
  32. import seaborn as sns
  33. for i in range(0,1018):
  34.     img=Image.open("F:\Thesis Files\Words2\%d.png" %i)
  35.     img=np.uint8(img)
  36.     img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  37.     tmp=img.shape
  38.     print(i)
  39.     print(tmp)
  40.     if len(tmp)==2:
  41.         img=cv2.merge([img,img,img])
  42.         print('sajid')
  43.     cv2.imwrite("%d.jpg" %(i),img)
  44. cv2.waitKey(0)
  45.        
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement