- # -*- coding: utf-8 -*-
- """
- Created on Thu Mar 7 11:14:23 2019
- @author: Student
- """
- #class VectorExample():
- # def __init__(self, input_list):
- # self.vector = input_list
- #
- # def foreach(self, other, input_function):
- # return VectorExample([input_function(self.vector[i], other.vector[i]) for i in range(len(self.vector))])
- #
- # def __add__(self,other):
- # return self.foreach(other, lambda a,b: a+b)
- #
- # def __sub__(self, other):
- # return self.foreach(other, lambda a,b: a-b)
- #
- # def __mul__(self, other):
- # return self.foreach(other, lambda a,b: a*b)
- #
- # def __truediv__(self,other):
- # return self.foreach(other, lambda a,b: a/b)
- #
- # def __str__(self):
- # return str(self.vector)
- #
- #
- #def run():
- # vector_1 = VectorExample([1, 13, 4])
- # vector_2 = VectorExample([3, -2, 2])
- #
- # print(vector_1 + vector_2)
- # print(vector_1 - vector_2)
- # print(vector_1 * vector_2)
- # print(vector_1 / vector_2)
- #
- #if __name__== "__main__":
- # run()
- import os
- import numpy as np
- from matplotlib import pyplot as plt
- from skimage import io
- import random
- #def run():
- # example_array = np.array([
- # [8,1,1,1],
- # [9,7,5,3],
- # [4,6,8,10],
- # [2,3,5,7]
- #
- # ])
- #
- # noise_1 = np.random.randn(128,256)
- # noise_2 = np.random.randn(128,256)
- #
- # vmin=-0.5;vmax=0.5
- # plt.figure()
- # plt.subplot(2,1,1)
- # plt.imshow(noise_1,cmap='gray', vmin=vmin, vmax=vmax)
- # plt.axis('off')
- # plt.subplot(2,1,2)
- # plt.imshow(noise_2, cmap='gray', vmin=vmin, vmax=vmax)
- # plt.axis('off')
- # plt.show()
- #
- #
- #
- #run()
- #def run():
- #
- # x_size = 512
- # y_size = 512
- # number_of_points = 500
- # vector1 = np.random.uniform(0,x_size,number_of_points)
- # vector2 = np.random.uniform(0,y_size,number_of_points)
- #
- # x_origin=256
- # y_origin=256
- # radius=100
- # is_inside=np.square(vector1-x_origin) + np.square(vector2-y_origin) < radius*radius
- #
- # image = np.zeros((y_size,x_size))
- # grid_x, grid_y = np.meshgrid(np.arange(x_size), np.arange(y_size))
- #
- # image[np.square(grid_x - x_origin)+np.square(grid_y - y_origin)<radius*radius] = 1
- #
- ## plt.figure()
- ## plt.subplot(1,2,1)
- ## plt.imshow(grid_x, cmap='gray')
- ## plt.subplot(1,2,2)
- ## plt.imshow(grid_y, cmap='gray')
- ## plt.show()
- #
- # vector1_inside = vector1[is_inside]
- # vector2_inside = vector2[is_inside]
- #
- # vector1_outside = vector1[np.logical_not(is_inside)]
- # vector2_outside = vector2[np.logical_not(is_inside)]
- #
- # plt.figure()
- # plt.imshow(image, cmap='gray')
- # plt.plot(vector1_inside, vector2_inside,"r.")
- # plt.plot(vector1_outside, vector2_outside, "b.")
- # plt.xlabel("X Coordinates")
- # plt.ylabel("Y Coordinates")
- # plt.xlin([0, x_size])
- # plt.ylin([0, y_size])
- # plt.legend(["Outside","Inside"])
- # plt.show()
- #
- #run()
- def run():
- current_path = os.path.abspath(os.path.dirname(__file__))
- image_folder=os.path.join(current_path, "sample_cifar")
- file_names = os.listdir(image_folder)
- random.shuffle(file_names)
- file_names = file_names[0:25]
- print(file_names)
- plt.figure()
- i=1
- for file_name in file_names:
- current_class = file_name.split('_')[1].split('.')[0].capitalize()
- plt.subplot(5,5,i)
- image_path = os.path.join(image_folder, file_name)
- image = io.imread(image_path)
- i+=1
- plt.axis('off')
- plt.title(current_class)
- plt.show()
- run()