91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4.69MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-11-05
  • 語言: Python
  • 標簽:

資源簡介

簡單線性非迭代算法產生超像素,與SLIC效果差不多,但是效率高

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-
“““
Created?on?Tue?Mar?20?11:10:24?2018

@author:?Administrator
“““

import?numpy?as?np
from?PIL?import?Image
from?skimage?import?color
import?math
from?Queue?import?PriorityQueue
import?cv2


def?findseeds(im_labwidthheightk):
????gridstep_x=int(math.sqrt(height*width/k)+0.5)
????gridstep_y=int(math.sqrt(height*width/k)+0.5)#compute?the?size?of?gridstep
????#compute?the?location?of?seeds?in?grid
????halfstep_x=int(gridstep_x/2)
????halfstep_y=int(gridstep_y/2)
????xsteps=int(width/gridstep_x)
????ysteps=int(height/gridstep_y)
????#compute?the?error?of?numberof?the?seeds
????err1=abs(xsteps*ysteps-k)
????err2=abs(int(width/(gridstep_x-1))*int(height/(gridstep_y-1))-k)
????if?err1??????gridstep_x=gridstep_x-1
??????gridstep_y=gridstep_y-1
??????xsteps=int(width/gridstep_x)
??????ysteps=int(height/gridstep_y)
????#compute?the?new?number
????numk=xsteps*ysteps
????ck=np.zeros((numk5))
????i=0;j=0;k=0
????for?i?in?range(ysteps):
????????for?j?in?range(xsteps):
????????????temp_x=halfstep_x+j*gridstep_x
????????????temp_y=halfstep_y+i*gridstep_y
????????????ck[k][0]=temp_x
????????????ck[k][1]=temp_y
????????????ck[k][2]=im_lab[temp_y][temp_x][0]
????????????ck[k][3]=im_lab[temp_y][temp_x][1]
????????????ck[k][4]=im_lab[temp_y][temp_x][2]
????????????k=k+1
????return(numkck)

def?initial_label(heightwidth):
????labels=np.zeros((heightwidth))
????for?i?in?range(height):
????????for?j?in?range(width):
????????????labels[i][j]=-1
????return(labels)

class?NODE(object):
????def?__init__(selfprioritydescription1description2description3):
????????distance=int()
????????xk=int()
????????yk=int()
????????k=int()
????????self.priority=distance
????????self.description1=xk
????????self.description2=yk
????????self.description3=k
????def?__cmp__(selfother):
????????return?cmp(self.priorityother.priority)

def?putinQ(ckQnumk):
????for?k?in?range(numk):
????????tempnode=NODE(0.0111)
????????tempnode.priority=0.0
????????tempnode.description1=ck[k][0]
????????tempnode.description2=ck[k][1]
????????tempnode.description3=k
????????Q.put(tempnode)
????return(Q)


def?runsnic(Qim_lablabelsnumkm):
????Qlength=Q.qsize()
????ksize=np.zeros((numk1))
????connectivity=4?#or?8
????p4_x=[1-100]
????p4_y=[001-1]
????LABXk=np.zeros((numk5))
????s=math.sqrt((height*width)/numk)
????#在這里選擇while的原因在于最終循環的截止條件為隊列長度為0,但是如果將Qlength作為循環
????#終止條件,它本身就是變的,我看資料說是最好使用while才能不出錯
????fnum=0
????while?Qlength>0:
????????temp=Q.get()
????????i=int(temp.description2)
????????j=int(temp.description1)
????????k=int(temp.description3)
????????if?labels[i][j]==-1:
????????????labels[i][j]=k
????????????fnum=fnum+1
????????????LABXk[k][0]=LABXk[k][0]+im_lab[i][j][0]
????????????LABXk[k][1]=LABXk[k][1]+im_lab[i][j][1]
????????????LABXk[k][2]=LABXk[k][2]+im_lab[i][j][2]
????????????LABXk[k][3]=LABXk[k][3]+j
????????????LABXk[k][4]=LABXk[k][4

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????4940240??2018-03-20?22:01??snic_超像素\Superpixels?and?Polygons?using?Simple?Non-Iterative?Clustering.pdf
?????文件????????5385??2018-03-23?10:43??snic_超像素\snic.py
?????目錄???????????0??2018-04-01?16:26??snic_超像素\

評論

共有 條評論

相關資源