1. 소스코드-자체 허프 변환을 한 경우# openCV 모듈을 import하여 불러옵니다.import cv2 as cv# pi 를 사용하기 위해 numpy 모듈을 import하여 불러옵니다.import numpy as np# 시간을 측정하기 위해 time 모듈을 import하여 불러옵니다.import time# 계산을 하기 위해 math 모듈을 import하여 불러옵니다.import math# start 변수에 현재 시간을 넣어줍니다.start=time.clock()# 변환시킬 이미지를 읽어옵니다.img= cv.imread('파일경로',파일이름)# 이미지를 gray 이미지로 변환시켜줍니다.gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)# gray 이미지를 가우시안 블러를 이용하여 노이즈를 제거합니다.blur = cv.GaussianBlur(gray, (5, 5), 0, 0)# Canny 함수를 이용하여 openCV의 edge를 검출합니다.edge = cv.Canny(blur, 50, 150, 3)height = edge.shape[0]width = edge.shape[1]tmp = max(height, width)hough_height = int(1.5 * tmp)# 2차원 배열인 accumulator를 만들기 위해 size를 정의해줍니다.accumulator_width = 180accumulator_height = hough_height * 2accumulator_size = accumulator_height * accumulator_width
1. 소스코드-자체 히스토그램 평활화한 경우import cv2import matplotlib.pyplot as pltimport numpy as np# 이미지를 grayscale의 이미지로 OpenCV의 함수 imread를 통해 불러옵니다. img = cv2.imread('[파일 경로].jpg',[파일 이름])# 1번째 단계 : 원래의 이미지의 빈도수를 hist에 표현합니다. hist=plt.hist(img.ravel(),bins=256,range=[0,256])# 2번째 단계 : 빈도수의 누적합을 cumsum이라는 함수를 이용하여 sum에 저장합니다. .hist, bin=np.histogram(img.ravel(),256,[0,256])sum=hist.cumsum()# 3번째 단계 : 정규화된 누적합을 구합니다.hist, bin=np.histogram(img.ravel(),256,[0,256])
1. 프로그램 소스package assignment;import java.util.Arrays;import java.util.Scanner;public class sorting {public static void main(String args[]) {int n;int arr[];String str;Scanner sc = new Scanner(System.in);System.out.print("n 값 입력 : ");// n을 입력 받는다.n = sc.nextInt();// n의 크기를 가진 동적배열을 생성한다.arr = new int[n];System.out.print(n+" 개의 정수 입력 : ");// n개의 수를 입력받아 배열에 넣는다.for(int i=0;i
public class SortMain {static void GreedySort(int a[], int n) { int a_min; int temp; int b_min; int min; // 배열 속 n개의 원소를 모두 뽑음 for(int i=0; i<n; i++){ // 맨 앞의 원소의 인덱스를 a_min, 그 다음의 원소의 인덱스를 b_min a_min = i; b_min=i+1; // 한 개의 원소를 제외한 나머지 원소에 대한 for문