国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? ??? ???? [Python-CV??? ?? : Canny Edge, Watershed ? K-Means ??

[Python-CV??? ?? : Canny Edge, Watershed ? K-Means ??

Dec 11, 2024 am 05:33 AM

??? ??, ?? ?? ??? ???? ???? ?? ?? ???? ?? ? ?? ??? ??? ?? ?????. ?? ?? ??, ??? ??, ??? ??? ??? ?? ?? ???? ???? ??? ???. ??? ??? ????? ???? ??? ? ????? ?????? OpenCV(cv2)? ????? ???? ??? ?? ??? ?????.

? ??????? ? ?? ?? ?? ??? ??? ???????.

  • ?? ?? ?? – ??? ??? ?? ? ?????.
  • ?? ???? – ??? ??? ???? ? ?????.
  • K-?? ?? ?? – ????? ??? ??? ??????? ? ??????.

? ????? ???? ????? ??? ?? ?? ?? ??? ???? ?? ???? ?? ? ?? ??? ???????. ????? GitHub ????? ??? ???? ?? ?? ???? ????? ? ????.

?? ??? ?? ?? ?? ??

?? ?? ??? ???? ??? ???? ?????? ??? ?????. ?? ?? ??? ??? ??? ?? ?? ??? ???? ?????. ? ??? ?? ???? ???? "?? ????" ???? ?????. OpenCV? ???? ??? ???????.

?: ?? ????? ???? ??
???? ???? ????, ?? ?? ??? ??? ??? ?????.

import cv2 
import numpy as np
import matplotlib.pyplot as plt
files = sorted(glob("SAT*.png")) #Get png files 
print(len(files))
img=cv2.imread(files[0])
use_image= img[0:600,700:1300]
gray = cv2.cvtColor(use_image, cv2.COLOR_BGR2GRAY)

#Stadard values 
min_val = 100
max_val = 200
# Apply Canny Edge Detection
edges = cv2.Canny(gray, min_val, max_val)
#edges = cv2.Canny(gray, min_val, max_val,apertureSize=5,L2gradient = True )
False
# Show the result
plt.figure(figsize=(15, 5))
plt.subplot(131), plt.imshow(cv2.cvtColor(use_image, cv2.COLOR_BGR2RGB))
plt.title('Original Image'), plt.axis('off')
plt.subplot(132), plt.imshow(gray, cmap='gray')
plt.title('Grayscale Image'), plt.axis('off')
plt.subplot(133), plt.imshow(edges, cmap='gray')
plt.title('Canny Edges'), plt.axis('off')
plt.show()

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

?? ?????? ?? ??? ?? ?? ??? ??? ???? ?????. ??? ???? ????? ?? ?? ??? ???????. ??? min_val ? max_val? ??? ??? ??? ?? ?? ?????.

???? ?? ??? ????? ?? ???? ????? ?? ??? ????? ???? ?? ? ????. ?? ????? ???(cv2.equalizeHist()) ? ??? ??(cv2.GaussianBlur())? ???? ??? ? ????.

use_image= img[0:600,700:1300]
gray = cv2.cvtColor(use_image, cv2.COLOR_BGR2GRAY)
gray_og = gray.copy()
gray = cv2.equalizeHist(gray)
gray = cv2.GaussianBlur(gray, (9, 9),1)

plt.figure(figsize=(15, 5))
plt.subplot(121), plt.imshow(gray, cmap='gray')
plt.title('Grayscale Image')
plt.subplot(122)
_= plt.hist(gray.ravel(), 256, [0,256],label="Equalized") 
_ = plt.hist(gray_og.ravel(), 256, [0,256],label="Original",histtype='step')
plt.legend()
plt.title('Grayscale Histogram')

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

??? ???? ?? ??? ??? ?? ???? ???? ?? Canny Edge ?? ????? ?? ?? ?? ????? ???? ? ??? ???.

????? ????? ??? ?????. ?? ??? ???? ?? ????? ????? ???? ??????.

# Edges to contours 
contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# Calculate contour areas
areas = [cv2.contourArea(contour) for contour in contours]

# Normalize areas for the colormap
normalized_areas = np.array(areas)
if normalized_areas.max() > 0:
    normalized_areas = normalized_areas / normalized_areas.max()

# Create a colormap
cmap = plt.cm.jet

# Plot the contours with the color map
plt.figure(figsize=(10, 10))
plt.subplot(1,2,1)
plt.imshow(gray, cmap='gray', alpha=0.5)  # Display the grayscale image in the background
mask = np.zeros_like(use_image)
for contour, norm_area in zip(contours, normalized_areas):
    color = cmap(norm_area)  # Map the normalized area to a color
    color = [int(c*255) for c in color[:3]]
    cv2.drawContours(mask, [contour], -1, color,-1 )  # Draw contours on the image

plt.subplot(1,2,2)

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

? ??? ??? ??? ?? ??? ???? ???? ?? ?????. ? ???? ??? ?? ??? ?????, ??? ??? ?? ????? ???? ? ??? ???. ??? ? ???? ?? ???? ??? ?? ????? ?? ????. ?? ??? ?? ???? ??? ?? ??? ?? ??? ??? ? ????.

???? ?? ??? ??? Canny Edge ??? ????? ?? ??? ???? ??? ??? ???. ??? ??? ? ???? ???? ???? ? ?? ? ?????. ???? K-?? ?????? ???? ???? ???? ???? ??? ???? ?? ?? ??? ???????.

KMean ?????

K-?? ?????? ??? ??? ????? ????? ??? ???? ?? ???? ????, ?? ???? ???? ???? ???? ? ?? ??????. OpenCV? cv2.kmeans ??? ? ????? ????? ?? ??, ?? ?? ?? ??? ??? ?? ??? ???? ? ?? ????.

? ????? K-Means Clustering? ???? ?? ?? ???? ??? ??? ???? ?????.

????? ???? RGB ?? K-?? ?????? ???? ? ??? ??? ???? ?????.

import cv2 
import numpy as np
import matplotlib.pyplot as plt
files = sorted(glob("SAT*.png")) #Get png files 
print(len(files))
img=cv2.imread(files[0])
use_image= img[0:600,700:1300]
gray = cv2.cvtColor(use_image, cv2.COLOR_BGR2GRAY)

#Stadard values 
min_val = 100
max_val = 200
# Apply Canny Edge Detection
edges = cv2.Canny(gray, min_val, max_val)
#edges = cv2.Canny(gray, min_val, max_val,apertureSize=5,L2gradient = True )
False
# Show the result
plt.figure(figsize=(15, 5))
plt.subplot(131), plt.imshow(cv2.cvtColor(use_image, cv2.COLOR_BGR2RGB))
plt.title('Original Image'), plt.axis('off')
plt.subplot(132), plt.imshow(gray, cmap='gray')
plt.title('Grayscale Image'), plt.axis('off')
plt.subplot(133), plt.imshow(edges, cmap='gray')
plt.title('Canny Edges'), plt.axis('off')
plt.show()

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

??? ?????? ??? ?? ??? ??? ???? ???? ????. ??? ???? ??? ?? ??? ?? ????? ????? ??? ??? ? ????.

???? ??? ? ???? ????? ??? ?? K-??? ???? ?? ??? ??? ??? ? ????.

use_image= img[0:600,700:1300]
gray = cv2.cvtColor(use_image, cv2.COLOR_BGR2GRAY)
gray_og = gray.copy()
gray = cv2.equalizeHist(gray)
gray = cv2.GaussianBlur(gray, (9, 9),1)

plt.figure(figsize=(15, 5))
plt.subplot(121), plt.imshow(gray, cmap='gray')
plt.title('Grayscale Image')
plt.subplot(122)
_= plt.hist(gray.ravel(), 256, [0,256],label="Equalized") 
_ = plt.hist(gray_og.ravel(), 256, [0,256],label="Original",histtype='step')
plt.legend()
plt.title('Grayscale Histogram')

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

??? ???? ?? ????? ? ?????? ???? ???? ??? ??? ????? ? ??? ?? ???.

?? ??? ? ? ???? ?? matplotlib plt.fill_between;? ???? ??? ???? ??? ?? ?? ?? ? ????.

# Edges to contours 
contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# Calculate contour areas
areas = [cv2.contourArea(contour) for contour in contours]

# Normalize areas for the colormap
normalized_areas = np.array(areas)
if normalized_areas.max() > 0:
    normalized_areas = normalized_areas / normalized_areas.max()

# Create a colormap
cmap = plt.cm.jet

# Plot the contours with the color map
plt.figure(figsize=(10, 10))
plt.subplot(1,2,1)
plt.imshow(gray, cmap='gray', alpha=0.5)  # Display the grayscale image in the background
mask = np.zeros_like(use_image)
for contour, norm_area in zip(contours, normalized_areas):
    color = cmap(norm_area)  # Map the normalized area to a color
    color = [int(c*255) for c in color[:3]]
    cv2.drawContours(mask, [contour], -1, color,-1 )  # Draw contours on the image

plt.subplot(1,2,2)

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

? ???? ???? ?? ??? ?? RGB ?? ?? ???? ????? ?? ??? ??? ? ????. ?? ? ?? ??? ????? ??? ??? ? ????.

???? ?(K)? ??? ? ??? ????. K? ??? ?? ???? ??? ????, ?? ???? ? ?? ???? ?????. ??? ?? ?? K ?? ??? ? ????.

import cv2 
import numpy as np
import matplotlib.pyplot as plt
files = sorted(glob("SAT*.png")) #Get png files 
print(len(files))
img=cv2.imread(files[0])
use_image= img[0:600,700:1300]
gray = cv2.cvtColor(use_image, cv2.COLOR_BGR2GRAY)

#Stadard values 
min_val = 100
max_val = 200
# Apply Canny Edge Detection
edges = cv2.Canny(gray, min_val, max_val)
#edges = cv2.Canny(gray, min_val, max_val,apertureSize=5,L2gradient = True )
False
# Show the result
plt.figure(figsize=(15, 5))
plt.subplot(131), plt.imshow(cv2.cvtColor(use_image, cv2.COLOR_BGR2RGB))
plt.title('Original Image'), plt.axis('off')
plt.subplot(132), plt.imshow(gray, cmap='gray')
plt.title('Grayscale Image'), plt.axis('off')
plt.subplot(133), plt.imshow(edges, cmap='gray')
plt.title('Canny Edges'), plt.axis('off')
plt.show()

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

??? K ?? ?? ????? ??? ????? ??? ??? ??? ?????.

??? K ?(?: 2-3): ??? ??? ?? ???? ????? ?? ?? ??? ?????.
?K ?? ????(?: 12-15): ? ????? ?????? ???? ???? ???? ???? ???? ????.

K-?? ?????? ?? ???? ???? ???? ???? ??? ?????. ??? ??? ??? ?? ???? ?? ?? ??? ?????. ??? ??? K? ??, ?? ???? ??, ??? ???? ?? ?????. ???? ??? ??? ???? ??? ??? ???? ???? ?? ????? ???????.

?? ??

?? ????? ??? ?? ??? ??? ????? ??? ?????. ? ??? ??? ?? ?? ??? ???? "???"? "???"? ????? ?????. ?? ??? ?????? ????? ??? ??? ??? ??? ? ????. ?? ??? ??? ???? ? ?? ????? ? ??, ?? ??, ??? ?? ??? ?? ??? ????? ??? ?????.

? ?? ??? ???? ????? ??? ??? ?? ?? ????? ???? ????.

use_image= img[0:600,700:1300]
gray = cv2.cvtColor(use_image, cv2.COLOR_BGR2GRAY)
gray_og = gray.copy()
gray = cv2.equalizeHist(gray)
gray = cv2.GaussianBlur(gray, (9, 9),1)

plt.figure(figsize=(15, 5))
plt.subplot(121), plt.imshow(gray, cmap='gray')
plt.title('Grayscale Image')
plt.subplot(122)
_= plt.hist(gray.ravel(), 256, [0,256],label="Equalized") 
_ = plt.hist(gray_og.ravel(), 256, [0,256],label="Original",histtype='step')
plt.legend()
plt.title('Grayscale Histogram')

??? ??? ??? ?? ?? ??? ?? ???? ? ????.

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods

# Edges to contours 
contours, hierarchy = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# Calculate contour areas
areas = [cv2.contourArea(contour) for contour in contours]

# Normalize areas for the colormap
normalized_areas = np.array(areas)
if normalized_areas.max() > 0:
    normalized_areas = normalized_areas / normalized_areas.max()

# Create a colormap
cmap = plt.cm.jet

# Plot the contours with the color map
plt.figure(figsize=(10, 10))
plt.subplot(1,2,1)
plt.imshow(gray, cmap='gray', alpha=0.5)  # Display the grayscale image in the background
mask = np.zeros_like(use_image)
for contour, norm_area in zip(contours, normalized_areas):
    color = cmap(norm_area)  # Map the normalized area to a color
    color = [int(c*255) for c in color[:3]]
    cv2.drawContours(mask, [contour], -1, color,-1 )  # Draw contours on the image

plt.subplot(1,2,2)

????? ??? ??? ????? ???? ?? ??? ??? ??? ????. ? ???? ?? ??? ???? ??????. ??? ????? ??? ??? ??, ??? ??, ???? ??? ?? ??? ??? ?? ?????.

????? ??? ?? ??? ?? ??? ?? ?? ???? ???? ??? ?? ??? ? ????. ?? ?? ??? ????.

# Kmean color segmentation
use_image= img[0:600,700:1300]
#use_image = cv2.medianBlur(use_image, 15)


 # Reshape image for k-means
pixel_values = use_image.reshape((-1, 3)) if len(use_image.shape) == 3 else use_image.reshape((-1, 1))
pixel_values = np.float32(pixel_values)

criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)
K = 3
attempts=10
ret,label,center=cv2.kmeans(pixel_values,K,None,criteria,attempts,cv2.KMEANS_PP_CENTERS)

centers = np.uint8(center)
segmented_data = centers[label.flatten()]
segmented_image = segmented_data.reshape(use_image.shape)

plt.figure(figsize=(10, 6))
plt.subplot(1,2,1),plt.imshow(use_image[:,:,::-1])
plt.title("RGB View")
plt.subplot(1,2,2),plt.imshow(segmented_image[:,:,[2,1,0]])
plt.title(f"Kmean Segmented Image K={K}")

[Python-CVImage Segmentation : Canny Edges, Watershed, and K-Means Methods
??? ??? ?? ? ?? ??? ???? ???? ??? ????? ???? ? ????.

?? ????? ??? ?? ??? ??? ??? ??? ??? ????? ?????. ??? ??? ???? ?? ?? ??? ?? ??? ???? ????? ??? ? ????. ??? ?? ??? ??? ???? ?? ? ???? ?? ????.

??

???? ??? ??? ?? ???, ??? ?? ??? ??? ???? ??? ? ?? ??? ?????. ? ??????? ?? ???? ??, K-?? ?????, ?? ??????? ? ?? ??? ?? ??? ????? ?? ?? ??????? ?? ???????. ???? ?? ?? ?? ???? ?? ?? ????? ? ?? ?? ??? ????? ??? ??? ?? ??? ???? OpenCV? ???? ?????.

?? ??? ??????? ? ?? ??? ???? ??? ?? ??? ??? ???. ?? ?? ??? ?? ??? ?? ???? ??????

? ??? [Python-CV??? ?? : Canny Edge, Watershed ? K-Means ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

?? ??

?? : ????? ????? ??
4 ? ? ? By DDD
?? ?? ??
3 ? ? ? By Jack chen
???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1787
16
Cakephp ????
1730
56
??? ????
1582
29
PHP ????
1449
31
???
?? ????? ???? ???? Python?? ??? ?????? ?? ????? ???? ???? Python?? ??? ?????? Jun 20, 2025 am 12:57 AM

?? ????? (DP)? ??? ??? ? ??? ?? ??? ??? ??? ? ??? ??? ?? ??? ???? ??? ????? ??????. ? ?? ?? ??? ????. 1. ??? (??) : ??? ?? ??? ???? ??? ???? ?? ??? ??????. 2. ??? (?) : ?? ???? ???? ????? ?????. ???? ???, ?? ?? ?? ?? ??/?? ?, ??? ??? ?? ?? ?? ??? ??? ????? ?????. ?????? ????? ?? ???? ?? ??? ? ???, ?? ??? ???? ?? ?? ??? ???? ??? ???? ????? ???? ???????.

??? ???? ????? ???? ?????? ??? ?????? ??? ???? ????? ???? ?????? ??? ?????? Jun 20, 2025 am 12:56 AM

Python? ?? ??? ???? ?????? ????, ????? ? ?? ??????? ???? ? ??? ??? ???? ?? ??? ?????. ?? TCP ??? ????? Socket.Socket ()? ???? ??? ??? ?? ? ??? ????? .listen ()? ???? ??? ?? .accept ()? ?? ????? ??? ???????. TCP ?????? ????? ?? ??? ??? ??? ????? .connect ()? ?? ? ?? .sendall ()? ???? ???? ??? .recv ()? ?? ??? ??????. ?? ?????? ????? 1. ??? : ??? ??? ? ???? ??? ? ????. 2. ??? I/O : ?? ??, Asyncio ?????? ? ??? ??? ?? ? ? ????. ???? ? ?

Python?? ??? ??? ???????? Python?? ??? ??? ???????? Jun 20, 2025 am 12:51 AM

Python List ????? ?? ?? ??? [Start : End : Step] ??? ????? ??? ???? ????. 1. ?? ????? ?? ??? ?? [start : end : step]???. ??? ?? ??? (??), ?? ? ??? (???? ??)?? ??? ?? ?????. 2. ????? ???? 0?? ????? ???? ????? ??? ??? ???? ????? ??? 1? ??????. 3. my_list [: n]? ???? ? ?? n ??? ?? my_list [-n :]? ???? ??? n ??? ????. 4. My_List [:: 2]? ?? ??? ?? ?? ??? ???? ??? ??? ?? ?? ?? ??? ???? ? ????. 5. ???? ???? ? ???? ???? ????

Python?? ??? ???? ???? ?? DateTime ??? ??? ?????? Python?? ??? ???? ???? ?? DateTime ??? ??? ?????? Jun 20, 2025 am 12:58 AM

Python? DateTime ??? ?? ?? ? ?? ?? ?? ??? ?? ? ? ????. 1. DateTime.now ()? ?? ?? ??? ??? ?? ? ??? ?? .date () ? .time ()? ?? ? ? ????. 2. DateTime (? = 2025, ? = 12, ? = 25, ?? = 18, ? = 30)? ?? ?? ?? ? ?? ??? ???? ?? ? ? ????. 3. .strftime ()? ???? ???? ???? ??????. ???? ??? %y, %m, %d, %h, %m ? %s; strptime ()? ???? ???? datetime ??? ?? ??????. 4. ?? ??? Timedelta? ??????

??? ???? ??? ??? ???? ??? Jul 05, 2025 am 02:58 AM

???? Python ?? ?? ?????? ?? ????, "??? ?????, ?? ??"? ???? ??? ??? ??? ?? ??? ?????. 1. ???? ?? ? ??? ?? ?????. ?? ???? ?? ??? ???? ??? ? ? ????. ?? ??, Spoke () ?? ???? ??? ??? ?? ??? ?? ????? ?? ??? ??? ????. 2. ???? ?? ???? ??? ??? ?????? Draw () ???? ???? ????? ?? ???? ?? ??? ???? ??? ???? ?? ?? ?? ??? ????? ?? ?? ????? ?? ?????. 3. Python ?? ???? ???????. ?? ???? ??? ???? ?? ???? ??? ????? ??? ?? ???? ??? ???? ????. ??? ??? ??? ???? ? ??? "?? ??"??????. 4. ???? ? ???? ?? ??? ?????

??? '?????, ??!' Python? ????? ??? '?????, ??!' Python? ????? Jun 24, 2025 am 12:45 AM

"?????, ??!" ????? Python?? ??? ?? ???? ????.? ?? ?? ??? ???? ?? ??? ???? ???? ??? ???? ? ?????. 1. ?? ?? ?? ( "Hello, World!")? ?? ????, ?? ? ??? ???? ???? ?????. 2. ?? ???? Python ??, ??? ???? ?? ?? ??, .py ??? ??, ????? ??? ???? ?? ?????. 3. ???? ???? ?? ? ?? ? ???, ?? ?? ??, .py ???? ???? ?? ?? ?? ??? ?????. 4. ?? ???? ?? ??? ??? ???, ??? ??? (? : Replit.com)? ?????.

???? ??? ???? ??? ??? ??? ?? ???? ??? ???? ??? ??? ??? ?? Jun 20, 2025 am 01:00 AM

tuplesinpytonarimmutabledartructureSedtostoreCollectionsofitems, wherelistsaremutable.tuplesAredefinedwithparenthesandcommas, supportIndexing, andcannotbemodifiedaftercreation, magememfasterandmoremoremory- ??? ?? .usetuplesfordatain

????? ??? ???? ??? ?????? ????? ??? ???? ??? ?????? Jun 21, 2025 am 01:02 AM

??? ???? ????? Python? Random ? String ?? ??? ??? ? ????. ?? ??? ??? ????. 1. ?? ? ??? ?? ?? ??; 2. String.ascii_letters ? String.Digits? ?? ?? ?? ?????. 3. ??? ??? ??????. 4. random.choices ()? ???? ???? ?????. ?? ??, ???? importrandom ? importString, set length = 10, arribution = string.ascii_letters.digits and execute '.join (random.c

See all articles