1. 부식 및 팽창
1.1 부식 작업
import cv2 import numpy as np img = cv2.imread('DataPreprocessing/img/dige.png') cv2.imshow("img", img) cv2.waitKey(0) cv2.destroyAllWindows()
dige.png 원본 사진 1 표시 (참고: 원본 사진이 없는 경우 스크린샷을 찍어 로컬에 저장할 수 있습니다.
후 1회 부식~ (반복=1)
kernel = np.ones((3, 3), np.uint8) erosion = cv2.erode(img, kernel, iterations=1) cv2.imshow('erosion', erosion) cv2.waitKey(0) cv2.destroyAllWindows()
부식 결과 표시 사진 2:
다중 부식원의 효과와 부식 원리
pie = cv2.imread('DataPreprocessing/img/pie.png') cv2.imshow('pie', pie) cv2.waitKey(0) cv2.destroyAllWindows()
pie.png원본 사진 3:
부식 원리, 필터의 부식 원리는 크기가 클수록 부식 정도도 커집니다그림 4:
kernel = np.ones((30, 30), np.uint8) erosion_1 = cv2.erode(pie, kernel, iterations=1) erosion_2 = cv2.erode(pie, kernel, iterations=2) erosion_3 = cv2.erode(pie, kernel, iterations=3) res = np.hstack((erosion_1, erosion_2, erosion_3)) cv2.imshow('res', res) cv2.waitKey(0) cv2.destroyAllWindows()
원형 부식의 세 가지 결과 표시그림 5:
1.2 확장 작업
kernel = np.ones((3, 3), np.uint8) dige_dilate = erosion dige_dilate = cv2.dilate(erosion, kernel, iterations=1) cv2.imshow('dilate', dige_dilate) cv2.waitKey(0) cv2.destroyAllWindows()
확장 전, 그림 2에서 선이 더 두꺼워진 것을 발견했습니다. 원본 그림과 비교한 선은 거의 동일하지만 수염이 긴 장치의 노이즈가 없습니다. 그림 6:
원을 여러번 확장한 효과이며, 팽창 원리는 부식과 반대입니다. 흰 반점이 있는 필터는 필터 안의 데이터가 모두 하얗게 변합니다.
pie = cv2.imread('DataPreprocessing/img/pie.png') kernel = np.ones((30, 30), np.uint8) dilate_1 = cv2.dilate(pie, kernel, iterations=1) dilate_2 = cv2.dilate(pie, kernel, iterations=2) dilate_3 = cv2.dilate(pie, kernel, iterations=3) res = np.hstack((dilate_1, dilate_2, dilate_3)) cv2.imshow('res', res) cv2.waitKey(0) cv2.destroyAllWindows()
원을 3번 확장한 결과, 그림 7:
2. 열기 작업 및 닫기 작업
2.1 열기 작업
# 开:先腐蚀,再膨胀 img = cv2.imread('DataPreprocessing/img/dige.png') kernel = np.ones((5, 5), np.uint8) opening = cv2.morphologyEx(img, cv2.MORPH_OPEN, kernel) cv2.imshow('opening', opening) cv2.waitKey(0) cv2.destroyAllWindows()
원본 그림 1을 변경하고 먼저 부식한 다음 확장하여 열기 작업 결과를 얻습니다그림 8:
2.2 닫힌 작업
# 闭:先膨胀,再腐蚀 img = cv2.imread('DataPreprocessing/img/dige.png') kernel = np.ones((5, 5), np.uint8) closing = cv2.morphologyEx(img, cv2.MORPH_CLOSE, kernel) cv2.imshow('closing', closing) cv2.waitKey(0) cv2.destroyAllWindows()
원본 그림 1을 먼저 확장한 다음 부식하여 열린 작업의 결과를 얻습니다.그림 9:
3 그라데이션 작업
원을 가져옵니다. 원본 그림 3, 확장을 5번, 침식을 5번 수행하고 빼기를 수행하여 윤곽선을 얻습니다.
# 梯度=膨胀-腐蚀 pie = cv2.imread('DataPreprocessing/img/pie.png') kernel = np.ones((7, 7), np.uint8) dilate = cv2.dilate(pie, kernel, iterations=5) erosion = cv2.erode(pie, kernel, iterations=5) res = np.hstack((dilate, erosion)) cv2.imshow('res', res) cv2.waitKey(0) cv2.destroyAllWindows() gradient = cv2.morphologyEx(pie, cv2.MORPH_GRADIENT, kernel) cv2.imshow('gradient', gradient) cv2.waitKey(0) cv2.destroyAllWindows()
그라디언트 연산 결과 얻기그림 10:
IV, 모자와 검은 모자
Top hat = 원본 입력 - open 연산 결과
# 礼帽 img = cv2.imread('DataPreprocessing/img/dige.png') tophat = cv2.morphologyEx(img, cv2.MORPH_TOPHAT, kernel) cv2.imshow('tophat', tophat) cv2.waitKey(0) cv2.destroyAllWindows()Get top hat 결과 그림 11:
4.2 Black hat
Black hat = 닫힌 연산 - 원본 Enter
# 黑帽 img = cv2.imread('DataPreprocessing/img/dige.png') blackhat = cv2.morphologyEx(img, cv2.MORPH_BLACKHAT, kernel) cv2.imshow('blackhat ', blackhat) cv2.waitKey(0) cv2.destroyAllWindows()모자 결과를 얻으려면사진 12:
위 내용은 Python+OpenCV의 형태학 연산 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Arraysinpython, 특히 비밀 복구를위한 ArecrucialInscientificcomputing.1) theaRearedFornumericalOperations, DataAnalysis 및 MachinELearning.2) Numpy'SimplementationIncensuressuressurations thanpythonlists.3) arraysenablequick

Pyenv, Venv 및 Anaconda를 사용하여 다양한 Python 버전을 관리 할 수 있습니다. 1) PYENV를 사용하여 여러 Python 버전을 관리합니다. Pyenv를 설치하고 글로벌 및 로컬 버전을 설정하십시오. 2) VENV를 사용하여 프로젝트 종속성을 분리하기 위해 가상 환경을 만듭니다. 3) Anaconda를 사용하여 데이터 과학 프로젝트에서 Python 버전을 관리하십시오. 4) 시스템 수준의 작업을 위해 시스템 파이썬을 유지하십시오. 이러한 도구와 전략을 통해 다양한 버전의 Python을 효과적으로 관리하여 프로젝트의 원활한 실행을 보장 할 수 있습니다.

Numpyarrayshaveseveraladvantagesstandardpythonarrays : 1) thearemuchfasterduetoc 기반 간증, 2) thearemorememory-refficient, 특히 withlargedatasets 및 3) wepferoptizedformationsformationstaticaloperations, 만들기, 만들기

어레이의 균질성이 성능에 미치는 영향은 이중입니다. 1) 균질성은 컴파일러가 메모리 액세스를 최적화하고 성능을 향상시킬 수 있습니다. 2) 그러나 유형 다양성을 제한하여 비 효율성으로 이어질 수 있습니다. 요컨대, 올바른 데이터 구조를 선택하는 것이 중요합니다.

tocraftexecutablepythonscripts, 다음과 같은 비스트 프랙티스를 따르십시오 : 1) 1) addashebangline (#!/usr/bin/envpython3) tomakethescriptexecutable.2) setpermissionswithchmod xyour_script.py.3) organtionewithlarstringanduseifname == "__"

numpyarraysarebetterfornumericaloperations 및 multi-dimensionaldata, mumemer-efficientArrays

numpyarraysarebetterforheavynumericalcomputing, whilearraymoduleisiMoresuily-sportainedprojectswithsimpledatatypes.1) numpyarraysofferversatively 및 formanceforgedatasets 및 complexoperations.2) Thearraymoduleisweighit 및 ep

ctypesallowscreatingandmanipulatingC-stylearraysinPython.1)UsectypestointerfacewithClibrariesforperformance.2)CreateC-stylearraysfornumericalcomputations.3)PassarraystoCfunctionsforefficientoperations.However,becautiousofmemorymanagement,performanceo


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경
