This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
gray_img = Image.open('Lenna.png').convert("LA")#밝기와 알파값을 이용해서 Grayscale로 변환 | |
gray_img.show()#grayscale로 변환된 흑백 이미지를 출력 | |
row = gray_img.size[0] | |
col = gray_img.size[1] | |
thr_img = Image.new("1", (row, col))#새 이진 이미지를 생성. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
gray_img = Image.open('Lenna.png').convert("LA")#밝기와 알파값을 이용해서 Grayscale로 변환 | |
gray_img.show()#grayscale로 변환된 흑백 이미지를 출력 | |
row = gray_img.size[0] | |
col = gray_img.size[1] | |
stretch_img = Image.new("L", (row, col))#새 흑백이미지를 생성. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
gray_img = Image.open('Lenna.png').convert("LA")#밝기와 알파값을 이용해서 Grayscale로 변환 | |
gray_img.save("lenna_gray.png")#grayscale로 변환된 흑백 이미지를 출력 | |
row = gray_img.size[0] | |
col = gray_img.size[1] | |
gamma1 = 0.88 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
gray_img = Image.open('Lenna.png').convert("LA")#밝기와 알파값을 이용해서 Grayscale로 변환 | |
gray_img.save("gray_lenna.png")#grayscale로 변환된 흑백 이미지를 출력 | |
row = gray_img.size[0] | |
col = gray_img.size[1] | |
rev_img = Image.new("L", (row, col))#새 흑백이미지를 생성. | |
for x in range(1 , row): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
import matplotlib.pyplot as plt | |
gray_img = Image.open('Lenna.png').convert("LA")#밝기와 알파값을 이용해서 Grayscale로 변환 | |
gray_img.save("gray_lenna.png")#grayscale로 변환된 흑백 이미지를 출력 | |
row = gray_img.size[0] | |
col = gray_img.size[1] | |
sliding_up_img = Image.new("L", (row, col))#새 흑백이미지를 생성. | |
sliding_down_img = Image.new("L", (row, col))#새 흑백이미지를 생성. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#입력 : int 자료형 2개, 시작 단을 int 자료형으로 입력받은 다음 마지막 단을 입력 받는다. | |
#출력 : 시작단부터 마지막단까지 짝수단만 2 * 1 = 2 형태로 한줄 씩 출력. | |
start_n = int(input())# 시작 단 입력 | |
end_n = int(input())# 마지막 단 입력 | |
for i in range(start_n, end_n+1): #start_n부터 end_n까지 반복 | |
if i % 2 == 0 : #i가 짝수일 때 | |
for j in range(1, 10):#1부터 9까지 반복 | |
print("%d * %d = %d"%(i, j, i*j)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#입력 : int 자료형 1개(n) | |
#출력 : n 의 길이를 가지는 숫자 피라미드 | |
n = int(input()) | |
for i in range(n): # 0부터 n-1까지 반복 | |
line_str = "" #해당 줄의 문자열을 선언 | |
for j in range(i+1):#0부터 i까지 반복 | |
line_str += str(j+1) #해당 줄 문자열에 해당 숫자를 더한다. | |
print(line_str)#해당 줄 출력 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import numpy as np | |
img_path = input("변환시킬 이미지의 경로를 입력하세요 : ")#크기를 변환할 이미지 경로 입력. | |
img = Image.open(img_path) | |
img.show("변환 전 이미지") | |
[height, width, band] = np.shape(img)# 이미지의 row, col, 채널 수 | |
height_rate = float(input("새로방향 변환 비율 : ")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import math | |
img_path = input("변환시킬 이미지의 경로를 입력하세요 : ")#크기를 변환할 이미지 경로 입력. | |
img = Image.open(img_path) | |
img.show("변환 전 이미지") | |
width, height = img.size#원본 이미지 크기 | |
width_rate = float(input("가로방향 변환 비율 : ")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eli5 | |
from eli5.sklearn import PermutationImportance | |
#model 이미 train이 끝난 모델 | |
perm = PermutationImportance(model).fit(val_X, val_y) | |
#각 feature들의 weight를 출력 | |
eli5.show_weights(perm, feature_names = val_X.columns.tolist()) |
OlderNewer