小编Cri*_*ngo的帖子

使用FFT在周期性边界条件下找到质心

我想用傅立叶变换在周期边界条件下找到模拟实体的中心; 周期性边界条件意味着,只要有东西从盒子的一侧出来,就会像在经典游戏小行星中一样扭曲出现在对面.

所以我所拥有的是每个时间帧的矩阵(Nx3),其中N是xyz中的点数.我想要做的是确定云的中心,即使它们都在周期性边界上移动,也就是说卡在两者之间.

我对解决方案的想法现在是对这些点进行(质量权重)直方图,然后对其进行FFT并使用第一个傅里叶系数的相位来确定最大值在框中的位置.

作为我用过的测试用例

import numpy as np
Points_x  = np.random.randn(10000)
Box_min   = -10
Box_max   =  10
X         = np.linspace( Box_min, Box_max, 100 )

### make a Histogram of the points
Histogram_Points = np.bincount( np.digitize( Points_x, X ),  minlength=100 )

### make an artifical shift over the periodic boundary
Histogram_Points = np.r_[ Histogram_Points[45:], Histogram_Points[:45] ]
Run Code Online (Sandbox Code Playgroud)

在周期性边界上移动的点的直方图

所以现在我可以使用FFT,因为它总是需要一个周期函数.

## doing fft
F = np.fft.fft(Histogram_Points)

## getting rid of everything but first harmonic
F[2:] = 0.

## back transforming
Fist_harmonic = np.fft.ifft(F) …
Run Code Online (Sandbox Code Playgroud)

python numpy fft

4
推荐指数
1
解决办法
1216
查看次数

图像检测中的线条和边缘有什么区别?

我们一直在学习像 Sobel 和 Roberts 的卷积矩阵这样的方法来检测图像中的边缘,扩展到 Canny 方法来清除它们。但是现在,我们正在学习“线”检测,而不是“边缘”检测 - 使用霍夫变换等方法。

问题是 - 我什至不知道如何概念化“线”和“边缘”之间的区别。有人可以在不使用复杂的数学方程等的情况下向我解释这种差异吗?

image image-processing edge-detection straight-line-detection

4
推荐指数
1
解决办法
4148
查看次数

Python 的 id 函数的 Matlab 等效项

Matlab 是否有任何等效于 Python 的id 功能?我尝试了一些类似 Python 的语法来创建一个 Matlab 表的副本,但很惊讶它实际上创建了一个带有一个变量的表,该变量的值是表,其变量名是表变量标识符。

我试图了解赋值在 Matlab 中是如何工作的,无论是通过引用还是创建副本,如果可能的话,我想获取对象的地址。

python memory matlab memory-management

4
推荐指数
1
解决办法
79
查看次数

如何平滑分段的 blob?

我沿着分段的斑点出现了一些闪烁(锐线)。如何减少它们以使边界更平滑?为了更清晰,我附上了带有输入和预期输出的图像。

请注意,它是一个二进制图像,我没有原始图像(灰色)。输入是二进制的。

我尝试过高斯模糊,但该方法使我的形状变小。

mask = ndimage.filters.gaussian_filter(mask, 0.5, order=0, output=None, mode='reflect', cval=0.0, truncate=5.0)
Run Code Online (Sandbox Code Playgroud)

示例输入和预期输出,如上所述

python algorithm image-processing

4
推荐指数
1
解决办法
687
查看次数

如何在 <ion-img> 上设置高度

我有一个离子页面,里面有一个ion-img

<ion-content>
  <ion-grid>
    <ion-row class="ion-padding" align-items-center justify-content-center>
      <ion-item>
        <ion-label text-wrap class="ion-text-center">
          Servicio de reportes
        </ion-label>
      </ion-item>
    </ion-row>
    <ion-row align-items-center justify-content-center >
      <ion-button size="smaill" type="submit" expand="block" routerDirection="forward" (click)="selectSource()" >Capturar imagen</ion-button>
    </ion-row>
    <ion-row>
      <ion-col>

        <ion-img [src]="selectedImage" *ngIf="selectedImage"> </ion-img>

      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content>
Run Code Online (Sandbox Code Playgroud)

当图片设置为selectedImage 时它会占据整个屏幕甚至更多。我必须滚动才能看到完整的图像。

我希望图像占据屏幕的 20% 或固定高度。

我试图在 css 中做到这一点:

ion-grid {
  height: 100%;

  ion-row {
    max-height: 33.33%;
  }
}
Run Code Online (Sandbox Code Playgroud)

而且我还尝试使用 height 属性:

 <ion-img height: 10rem; [src]="selectedImage" *ngIf="selectedImage"> </ion-img>
Run Code Online (Sandbox Code Playgroud)

并且图像继续占据相同的空间

我该怎么做?感谢帮助。

html css image ionic-framework ionic4

4
推荐指数
2
解决办法
1万
查看次数

IFFT在Python中返回什么?

我需要复杂数组的傅立叶逆变换。ifft应该返回一个实数组,但它返回另一个复杂数组。

在MATLAB中 a=ifft(fft(a)),但是在Python中,它不能那样工作。

a = np.arange(6)
m = ifft(fft(a))
m # Google says m should = a, but m is complex
Run Code Online (Sandbox Code Playgroud)

输出:

array([0.+0.00000000e+00j, 1.+3.70074342e-16j, 2.+0.00000000e+00j,
       3.-5.68396583e-17j, 4.+0.00000000e+00j, 5.-3.13234683e-16j])
Run Code Online (Sandbox Code Playgroud)

python fft

4
推荐指数
2
解决办法
490
查看次数

绘制归一化均匀混合物

我需要在下面重现归一化密度 p(x),但给出的代码不会生成归一化 PDF。

x 的 p 绘图

clc, clear
% Create three distribution objects with different parameters
pd1 = makedist('Uniform','lower',2,'upper',6);
pd2 = makedist('Uniform','lower',2,'upper',4);
pd3 = makedist('Uniform','lower',5,'upper',6);
% Compute the pdfs
x = -1:.01:9;
pdf1 = pdf(pd1,x); 
pdf2 = pdf(pd2,x); 
pdf3 = pdf(pd3,x); 
% Sum of uniforms
pdf = (pdf1 + pdf2 + pdf3);
% Plot the pdfs
figure;
stairs(x,pdf,'r','LineWidth',2);
Run Code Online (Sandbox Code Playgroud)

如果我通过简单地按它们的总和缩放它们来计算归一化混合 PDF,与上面的原始图相比,我有不同的归一化概率。

pdf = pdf/sum(pdf);
Run Code Online (Sandbox Code Playgroud)

matlab distribution probability-density uniform-distribution mixture

4
推荐指数
1
解决办法
420
查看次数

为什么在预处理图像数据时,我们需要做以零为中心的数据?

为什么在为神经网络预处理图像数据时,我们需要以零为中心的数据。为什么是这样?

图片

machine-learning computer-vision neural-network deep-learning

4
推荐指数
1
解决办法
2434
查看次数

如何在图像的拉普拉斯高斯算子中找到零交叉点

我需要仅使用我的方法以及 matplotlib OpenCV 和 NumPy 构建 LoG 文件管理器(而不是仅使用过滤器来帮助计算的内置函数)

def edgeDetectionZeroCrossingLOG(img: np.ndarray) -> (np.ndarray):
    """
    Detecting edges using the "ZeroCrossingLOG" method
    :param I: Input image
    :return: :return: Edge matrix
    """
    kernel = np.ndarray((3, 3))
    b_img = blurImage1(img, kernel)
    k = np.array([[0, 1, 0],
                  [1, -4, 1],
                  [0, 1, 0]])
    img_dervative = conv2D(img, k)
    ***Zero-Crossing***
Run Code Online (Sandbox Code Playgroud)

脚步:

  1. 使用高斯滤波器模糊图像
def blurImage1(in_image: np.ndarray, kernel_size: np.ndarray) -> np.ndarray:
    """
    Blur an image using a Gaussian kernel
    :param inImage: Input image
    :param kernelSize: Kernel size
    :return: The …
Run Code Online (Sandbox Code Playgroud)

python image-processing computer-vision laplacianofgaussian

4
推荐指数
1
解决办法
4045
查看次数

Matlab计算L2范数非常慢

我有以下 MATLAB 片段:

>> R = randn(3000,6000);   % build a random 3000 by 6000 matrix
>> tic; norm(R, 1); toc;
Elapsed time is 0.005586 seconds.
>> tic; norm(R, 2); toc;
Elapsed time is 3.019667 seconds.
>> tic; norm(R, inf); toc;
Elapsed time is 0.005393 seconds.
>> 
Run Code Online (Sandbox Code Playgroud)

我的问题是,为什么 L2 范数计算比 L1 或 L 无穷范数慢得多?当然,这是一个用于测试目的的随机矩阵,但对于我工作中的实际矩阵,我可以在经过的时间方面看到类似的模式。

然而在Julia上,结果如下

julia> @time norm(R, 1);
  0.007156 seconds (1 allocation: 16 bytes)

julia> @time norm(R, 2);
  0.009142 seconds (1 allocation: 16 bytes)

julia> @time norm(R, Inf);
  0.034633 seconds …
Run Code Online (Sandbox Code Playgroud)

performance matlab matrix linear-algebra julia

4
推荐指数
1
解决办法
506
查看次数