小编Cri*_*ngo的帖子

Python 的 id 函数的 Matlab 等效项

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

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

python memory matlab memory-management

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

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

我需要仅使用我的方法以及 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中创建一个字符串数组?

我想将一个字符串向量从C++传递给matlab.我已经尝试使用可用的函数,如mxCreateCharMatrixFromStrings,但它没有给我正确的行为.

所以,我有这样的事情:

void mexFunction(
    int nlhs, mxArray *plhs[],
    int nrhs, const mxArray *prhs[])
{
   vector<string> stringVector;
   stringVector.push_back("string 1");
   stringVector.push_back("string 2");
   //etc...
Run Code Online (Sandbox Code Playgroud)

问题是我如何将这个向量带到matlab环境中?

   plhs[0] = ???
Run Code Online (Sandbox Code Playgroud)

我的目标是能够运行:

>> [strings] = MyFunc(...)
>> strings(1) = 'string 1'
Run Code Online (Sandbox Code Playgroud)

c++ matlab mex

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

如何使用 Makefile 和 Inkscape 保存为“普通 SVG”

在 make 文件中使用--verb=FileSave --verb=FileQuit将 SVG 保存为Inkscape SVG,其中包含大量 Inkscape 窗口查看信息。

我试图通过保存为纯 SVG来摆脱它,以减少文件大小,但似乎没有特定的VERB-ID来执行此操作。

我需要对脚本进行哪些修改,以便在生成 SVG 时消除 SVG 中的额外信息?

svg makefile image inkscape

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

从图像中识别井字游戏板的状态

我正在开发一个项目,我必须在java中使用openCV来识别井字游戏板的状态。请参阅下面的示例程序执行。

输入

井字游戏板的示例图像

输出

X,-,-

-,O,-

X,-,-
Run Code Online (Sandbox Code Playgroud)

我试图通过查找图像中的轮廓来解决此问题,但问题是未标记的空框也被捕获,并且我无法使用多边形大小和轮廓面积等轮廓属性来区分形状。下面是我到目前为止的代码。

package finalproject;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfInt;
import org.opencv.core.MatOfPoint;
import org.opencv.core.MatOfPoint2f;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;


public class FinalProject {
    public static void main(String[] args) {

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    Mat image = Imgcodecs.imread("C://Users//BadarJahan//Desktop//board- 
    perfect.jpg");

    Mat binaryImage = preprocess(image);

    List<MatOfPoint> contours = new ArrayList<>();
    Imgproc.findContours(binaryImage, contours,new Mat() ,Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_SIMPLE);
    List<MatOfPoint2f> contoursConvert = new ArrayList<>();

    for(MatOfPoint contour : contours) {
        contoursConvert.add(new MatOfPoint2f(contour.toArray()));
    }

    identifyTicTacToeConfiguration(binaryImage,contoursConvert);

} …
Run Code Online (Sandbox Code Playgroud)

java opencv image-processing tic-tac-toe opencv3.0

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

使用 fprintf() 和 disp() 函数在 MATLAB 中的命令窗口中显示消息?

目前正在开发一个项目,其中我必须接受多个用户输入。因为我的输入提示必须向用户概述有关如何输入值的特定格式,这使得每个输入提示相当冗长,因此我认为用换行符分隔每个输入提示是合适的,以便很容易区分它们/这样看起来就不错了。最后一个提示有两行长,因此如果它们都混杂在一起而不是用换行符分隔,则很难将其与其他提示区分开来。

fprintf()我已经探索了和的用法disp(),并发现它fprintf()有一些棘手的行为,有时如果不包含诸如 等之类的东西就无法工作fflushf()。此外,我读到它fprintf()实际上是用于将数据写入文本文件(来自 MathWorks 页面) ,至少),并且将其用于其他目的,如果确实有更简单的方法,我肯定会看到我的教授扣分(我们对脚本效率的评分非常严格)。

disp()命令似乎更符合我正在寻找的内容,但是我找不到任何能够支持\n. 目前,我已经采用了替换\nwith的用法disp(' '),但这肯定会导致扣分。

TL;DR有没有更有效的方法来创建换行符而不使用fprintf('text\n')?我将附上我的脚本的一部分供您查看:

disp('i) For the following, assume Cart 1 is on the left and Cart 3 is on the right.');
disp('ii) Assume positive velocities move to the right, while negative velocities move to the left.');
prompt = '\nEnter an array of three cart masses (kg) in the form ''[M1 M2 M3]'': '; …
Run Code Online (Sandbox Code Playgroud)

formatting matlab newline

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

用于 3D 图像体积的 SSIM

我正在使用 TensorFlow 处理图像超分辨率问题(2D 和 3D),并且正在使用 SSIM 作为eval_metrics.

我正在使用image.ssim来自 TF 和measure.comapre_ssim来自skimage. 它们都为 2D 提供了相同的结果,但 3D 体积的结果总是有所不同。

我已经查看了TF-implementationskimage-implementation的源代码。在两种实现中如何考虑和处理输入图像似乎存在一些根本差异。

复制问题的代码:

import numpy as np
import tensorflow as tf

from skimage import measure

# For 2-D case
np.random.seed(12345)
a = np.random.random([32, 32, 64])
b = np.random.random([32, 32, 64])

a_ = tf.convert_to_tensor(a)
b_ = tf.convert_to_tensor(b)

ssim_2d_tf = tf.image.ssim(a_, b_, 1.0)
ssim_2d_sk = measure.compare_ssim(a, b, multichannel=True, gaussian_weights=True, data_range=1.0, use_sample_covariance=False)

print (tf.Session().run(ssim_2d_tf), ssim_2d_sk)

# For …
Run Code Online (Sandbox Code Playgroud)

image-processing python-2.7 ssim scikit-image tensorflow

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

像在 Python 中一样创建 MATLAB 字典

我想知道 MATLAB 中是否有一种方法可以像 Python 一样创建字典。

我有几个端口名称和端口类型,我想创建一个像这样的字典:

dict = {PortName : PortType, PortName : PortType, ...}
Run Code Online (Sandbox Code Playgroud)

matlab dictionary

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

计算精度

如果 x 和 y 都可以(精确地)以浮点形式存储在系统中,那么计算精度会是多少。

x - (x/y) * y
Run Code Online (Sandbox Code Playgroud)

floating-point precision matlab floating-accuracy

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

尝试导入 Crypto 包时出错

当我发出这些导入命令时:

import sys
import cv2
import numpy as np
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
from Crypto.Random import get_random_bytes
Run Code Online (Sandbox Code Playgroud)

我看到这个错误消息:

File "C:/Users/user/Desktop/image-encryption-main/PyImgEnc.py", line 4, in <module>
        from Crypto.Cipher import AES
    ModuleNotFoundError: No module named 'Crypto'
Run Code Online (Sandbox Code Playgroud)

这些是我安装的库:

pip install wheel
pip install scipy
pip install pbkdf2
pip install pyaes
pip install pycryptodome
Run Code Online (Sandbox Code Playgroud)

我怎么解决这个问题?

python encryption pip image-processing

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