小编Cri*_*ngo的帖子

将自定义标签添加到 TIFF 文件

我\xe2\x80\x99m对libtiff相当陌生,但我\xe2\x80\x99已经设法获得tiff文件\n保存和打开没有太多麻烦。

\n\n

现在,我\xe2\x80\x99m雄心勃勃,并尝试将自定义标签添加到我的文件中。我\xe2\x80\x99ve\n阅读了文档(请参阅此处)并编写了一些测试代码,这些代码编译时没有\n错误,但在运行时失败,并在第一次调用\n具有自定义字段的 TIFFSetField 时发生访问冲突(调用 TIFFSetField带有\n标准字段就可以了)。

\n\n

我的测试代码如下:不到 100 行,唯一的外部依赖项(除了 libtiff)是我从 .pgm 文件打开测试图像的代码。谁能指出我\xe2\x80\x99m 做错了什么?顺便说一句,我正在使用 libtiff 4.0.3。

\n\n
#include "stdafx.h"\n#include "PGM.h"      // Just for reading in the test image\n#include "tiffio.h"\n\n// There are a number of TIFF-related definitions we need to make in order to support the custom tags\n// that we want to include in our files. The form of these definitions and subroutines comes straight\n// out of the libtiff documentation, and the values of the custom tags themselves come …
Run Code Online (Sandbox Code Playgroud)

c c++ tiff libtiff

5
推荐指数
1
解决办法
6575
查看次数

Scipy ndimage 形态学运算符使我的计算机内存 RAM (8GB) 饱和

我需要使用半径为 17 或更大的 3D 结构元素来计算 3D 形状数组 (400,401,401)、大小为 64320400 字节的形态学开度。结构元素 ndarray 的大小为 42875 字节。使用scipy.ndimage.morphology.binary_opening,整个过程消耗 8GB RAM。

I have read scipy/ndimage/morphology.py on GitHub, and as far as I can tell, the morphology erosion operator is implemented in pure C. It is to difficult for me to understand the ni_morphology.c source, so I haven't found any part of this code which leads to such enormous memory utilization. Adding more RAM is not a workable solution, since memory usage may increase …

python numpy image-processing scipy mathematical-morphology

5
推荐指数
2
解决办法
1193
查看次数

在 Octave 中创建具有多个绘图的动画

我正在使用 Octave 编写一个脚本来绘制不同时间段的函数。我希望制作一个情节动画,以便看到随时间的变化。

有没有办法保存每个时间点的每个图,以便可以组合所有图来创建此动画?

plot animation octave

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

返回一个实值,相位扰乱的时间序列

我正在尝试使用Scipy/Numpy在Python中实现时间序列的"相位加扰".简而言之,我想:

  1. 拿一个时间序列.
  2. 使用FFT测量频域中的功率和相位.
  3. 扰乱现有阶段,随机重新分配阶段到频率.
  4. 使用IFFT返回具有加扰相位的实值(即,非复数)时间序列,使得时间序列的功率谱保持不变,但是时间序列的点与原始点不同.

我有一个表面上似乎有用的脚本(见图),但我怀疑我错过了一些重要的东西.特别是,我返回的阶段扰码时间序列具有复值条目而不是实值条目,我不知道该怎么做.如果任何信号处理人员可以权衡并教育我,我会非常感激.

这是适用于Jupyter Notebook的示例脚本:

%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from scipy.fftpack import fft, ifft

def phaseScrambleTS(ts):
    """Returns a TS: original TS power is preserved; TS phase is shuffled."""
    fs = fft(ts)
    pow_fs = np.abs(fs) ** 2.
    phase_fs = np.angle(fs)
    phase_fsr = phase_fs.copy()
    np.random.shuffle(phase_fsr)
    fsrp = np.sqrt(pow_fs) * (np.cos(phase_fsr) + 1j * np.sin(phase_fsr))
    tsr = ifft(fsrp)
    return tsr

ts = np.array([0.02, -1.04, 2.50, 2.21, 1.37, -0.05, 0.06, -0.22, -0.48, -0.31, …
Run Code Online (Sandbox Code Playgroud)

python signal-processing numpy fft scipy

5
推荐指数
1
解决办法
521
查看次数

傅里叶滤波,回到图像

我的数据上有重复的条纹图案,我试图通过傅立叶变换它并删除图案来将其取出。但是我似乎无法找到返回图像空间的正确方法。

red_cube_array = (cube_array - np.median(cube_array)) * taper

im_fft  = (fftpack.fft2(red_cube_array))
im_po   = fftpack.fftshift((np.conjugate(im_fft) * im_fft).real)

mask = np.empty_like(im_po[0])*0 + 1
mask[417:430, 410:421] = 0
mask[430:443, 438:450] = 0

im_po_mask = im_po * mask

im_ifft = fftpack.ifft2(fftpack.ifftshift(im_po_mask))
Run Code Online (Sandbox Code Playgroud)

taper只是一个在执行 FFT 时平滑边缘以消除边缘效应的数组。然后我对数组进行 FFT 并非常粗略地过滤掉垃圾。然而,回去似乎不起作用。我是不是在某个地方绊倒了?

python filtering fft

5
推荐指数
1
解决办法
269
查看次数

查找图像是亮还是暗

我想知道如何使用 OpenCV 在 Python 3 中编写一个函数,它接收图像和阈值,并在严重模糊并降低质量(越快越好)后返回“暗”或“亮”。这听起来可能含糊不清,但任何有效的方法都行。

python opencv image-processing opencv-python

5
推荐指数
3
解决办法
9597
查看次数

如何检查轴手柄是否被清除

我想检查是否已清除某些轴,根据这些轴执行某些进一步的任务.我cla用来清除一些轴,而不是delete.例如:

figure

hs1 = subplot(121); plot(rand(100,2), 'x');

hs2 = subplot(122); plot(rand(100,2), 'o');

cla(hs1)
Run Code Online (Sandbox Code Playgroud)

然后,问题是如何确定是否hs1被清除.

matlab matlab-figure

5
推荐指数
1
解决办法
40
查看次数

如何根据孔的数量计算物体

我正在处理具有形状的图像,并且我正在尝试计算具有 1 个孔的对象和具有 2 个孔的对象。

伊格

我找到了关于它的信息,但它是在 MATLAB 中将 那些有孔的对象分割出来 他们使用了 Euler 特性,我知道在 Python 中存在 skimage 库,但我不能使用它。

我也找到了一些代码,但我无法理解。http://www.cis.rit.edu/class/simg782/homework/hw3/hw3solutions.pdf第 16 页。

PRO hw3 4,A,LA,LC,count
;Find all the holes
Ac=A EQ 0
LC=label region(Ac,/ALL)
;Construct an array with the holes filled in
Afill=(A GT 0) OR (LC GT 1)
;Display the arrays
sa=size(A,/dim)
window,/free,xsize=sa[0],ysize=sa[1]
tvlct,rr,gg,bb,/get
tek color
TV,Afill
window,/free,xsize=sa[0],ysize=sa[1]
TV,LC
;Count the objects with holes. First we
;find all the objects and then match up
;the object labels and the hole …
Run Code Online (Sandbox Code Playgroud)

python image-processing python-3.x

5
推荐指数
1
解决办法
1987
查看次数

如何重新采样多索引数据帧内的数据

我有以下数据框:在此处输入图片说明

我需要重新采样数据来计算每周的 pct_change()。我怎样才能获得每周的变化?

有点像,data['pct_week'] = data['Adj Close'].resample('W').ffill().pct_change()但数据需要分组data.groupby(['month', 'week'])

这样每个月都会产生 4 个每周变化的值。然后我可以绘制

我所做的是df['pct_week'] = data['Adj Close'].groupby(['week', 'day']).pct_change()但我收到了这个错误TypeError: 'type' object does not support item assignment

datetime resampling dataframe python-3.x pandas

5
推荐指数
1
解决办法
481
查看次数

为什么在不同版本的 MATLAB(2016 与 2021)中得到不同的结果?

为什么使用在不同版本的 MATLAB(2016 与 2021)中运行的相同代码来计算sum(b.*x1)其中bis single 和x1is double 时会得到不同的结果。如何避免MATLAB版本之间出现此类错误?

MATLAB v.2021:

sum(b.*x1)

ans =

  single

  -0.0013286
Run Code Online (Sandbox Code Playgroud)

MATLAB 2016

sum(b.*x1)

ans =

  single

  -0.0013283
Run Code Online (Sandbox Code Playgroud)

matlab

5
推荐指数
1
解决办法
419
查看次数