日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

第10章 Python 数字图像处理(DIP) - 图像分割 基础知识 标准差分割法

發(fā)布時間:2023/12/10 python 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第10章 Python 数字图像处理(DIP) - 图像分割 基础知识 标准差分割法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

This Chapter is all about image segmentation.
I still not finished whole chapter, but here try to publish some for reference.

這里寫目錄標題

    • 基礎知識

import sys import numpy as np import cv2 import matplotlib import matplotlib.pyplot as plt import PIL from PIL import Imageprint(f"Python version: {sys.version}") print(f"Numpy version: {np.__version__}") print(f"Opencv version: {cv2.__version__}") print(f"Matplotlib version: {matplotlib.__version__}") print(f"Pillow version: {PIL.__version__}") def normalize(x, ymin=0, ymax=1):"""Description:- Map x into desired range[ymin, ymax], according to the math function $$y = \frac{(y_{\text{max}} - y_{\text{min}}) (x - x_{\text{min}})}{(x_{\text{max}} - x_{\text{min}})} + y_{\text{min}}$$Parameters:- x: input array- ymin: desired min value, such as -1, or whatever you want- ymax: desired max value, such as 1, or other you need"""result = (ymax - ymin) * (x - x.min()) / (x.max()-x.min()) + ymin#################### old one ####################### result = (x - x.min()) / (x.max() - x.min())return result

基礎知識

RRR表示一幅圖像占據(jù)的整個空間區(qū)域。我們可以將圖像分割視為把RRR分為nnn個子區(qū)域R1,R2,?,RnR_1,R_2,\cdots,R_nR1?R2??Rn?的過程,滿足:

  • (a) ?i=1nRi=R\bigcup_{i=1}^{n} R_{i} = R?i=1n?Ri?=R
  • (b) Ri,i=0,1,2,?,nR_{i}, i=0, 1, 2, \cdots, nRi?,i=0,1,2,?,n 是一個連通集。
  • (c) 對所有iiijjji≠j,Ri?Rj=?i\neq j, R_{i}\bigcap R_{j} = \emptyseti?=j,Ri??Rj?=?
  • (d) Q(Ri)=TRUE,i=0,1,2,?,nQ(R_{i})=TRUE, i=0, 1, 2, \cdots, nQ(Ri?)=TRUE,i=0,1,2,?,n
  • (e) 對于任何鄰接區(qū)域RiR_{i}Ri?RjR_{j}Rj?Q(Ri?Rj)=FALSEQ(R_{i} \bigcup R_{j}) = FALSEQ(Ri??Rj?)=FALSE

其中Q(Ri)Q(R_{i})Q(Ri?)是定義在集合RkR_{k}Rk?中的點上的一個謂詞邏輯。

def std_seg(image, thred=0, stride=4):"""Description:Segment image caculating standard deviationParemeters:image: input grayscale imagethred: thredshold of the standard diviationstride: control the neighborhoodReturn:Binary segment image"""h, w = image.shape[:2]result = image.copy()# here we use stride the create non-overlap region, if we not need stride here, we still can get very good result# or we set stride smaller than 8, then we can get better resultfor i in range(0, h, stride):for j in range(0, w, stride):temp = image[i:i+stride, j:j+stride]if np.std(temp) <= thred:result[i:i+stride, j:j+stride] = 0else:result[i:i+stride, j:j+stride] = 255return result # standard deviation segment, according the result below, it seems the img_f is not 8x8 region, is about 4-5 img_d = cv2.imread("DIP_Figures/DIP3E_Original_Images_CH10/Fig1001(d)(noisy_region).tif", -1) img_seg = std_seg(img_d, thred=0, stride=5)fig = plt.figure(figsize=(10, 5)) plt.subplot(1, 2, 1), plt.imshow(img_d, 'gray'), plt.xticks([]), plt.yticks([]) plt.subplot(1, 2, 2), plt.imshow(img_seg, 'gray'), plt.xticks([]), plt.yticks([]) plt.tight_layout() plt.show()

總結

以上是生活随笔為你收集整理的第10章 Python 数字图像处理(DIP) - 图像分割 基础知识 标准差分割法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。