小编Jos*_*lez的帖子

使用 ndimage.maximum_filter 和 skimage.peak_local_max 查找图像峰值

我试图找到给定图像的一些相对最大值。据我所知,有两种可能的方法,第一种是使用scipy.ndimage.maximum_filter(),第二种是使用 skimage.feature.peak_local_max()

为了比较这两种方法,我修改了此处显示的skimage 的示例,以便比较找到的峰值。

from scipy import ndimage as ndi
import matplotlib.pyplot as plt
from skimage.feature import peak_local_max
from skimage import data, img_as_float

im = img_as_float(data.coins())

# use ndimage to find the coordinates of maximum peaks
image_max = ndi.maximum_filter(im, size=20) == im

j, i = np.where(image_max)
coordinates_2 = np.array(zip(i,j))

# use skimage to find the coordinates of local maxima
coordinates = peak_local_max(im, min_distance=20)

# display results
fig, axes = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True) …
Run Code Online (Sandbox Code Playgroud)

python scikit-image ndimage

7
推荐指数
1
解决办法
5996
查看次数

与 fsharp 中的等于运算符进行比较

如果我有下一种类型:

type Color(r: float, g: float, b:float) =
  member this.r = r
  member this.g = g
  member this.b = b
  static member ( * ) (c1:Color, c2:Color) =
      Color (c1.r*c2.r, c1.g*c2.g, c1.b*c2.b)

  static member Zero = Color(0.0,0.0,0.0)
Run Code Online (Sandbox Code Playgroud)

我这样做:

let ca = Color(1.,1.,1.)
let cb = Color(1.,1.,1.)
ca = cb
Run Code Online (Sandbox Code Playgroud)

我应该获得true,但是通过脚本进行的 F# 交互却给了我false 相反,如果我定义为:

let ca = Color(1.,1.,1.)
let cb = ca
ca = cb
Run Code Online (Sandbox Code Playgroud)

它返回true 我尝试以这种方式比较定义类型的两个值是否做错了什么?我怎样才能得到正确的结果?

谢谢

f# f#-interactive

3
推荐指数
1
解决办法
1442
查看次数

标签 统计

f# ×1

f#-interactive ×1

ndimage ×1

python ×1

scikit-image ×1