zoukankan      html  css  js  c++  java
  • matlab转python

      最近在做把matlab代码转成python代码,没有用过matlab,python也只是局限于爬虫,所以....

      matlab与python最大的不同是,matlab的下标是从1开始的,python和C语言C++都是下标从0开始的,在matlab中,对图片缩放,有一个imresize函数,Resize the image, specifying scale factor and using default interpolation method and antialiasing.在Python在,有resize函数,但是对图片的缩放效果不同。

      matlab中的kmean 

    [cluster_idx cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean','Replicates',1,'EmptyAction','drop', 'Options',opts);

    在Python中:

    nColors = 5
    cluster_idx = KMeans(n_clusters=nColors, max_iter=38,n_init=40, init='k-means++',n_jobs=-1).fit(ab)
    cluster__center = cluster_idx.cluster_centers_
     

    在matlab中有有从rgb转化成lab的图片

    if  length(size(I)) >2
         I=rgb2gray(I);

    在python中当图片的维度大于2时,进行转换,并且在转换前,都要将矩阵里面的值转换成int类型。

       image_orig = image_orig.astype(np.uint8)
        if len(num) > 2:
            lab_he = cv2.cvtColor(image_orig,cv2.COLOR_BGR2LAB)
        else:
            lab_he = image_orig
  • 相关阅读:
    S3C2440实现dm9000网卡驱动程序移植
    IMX257虚拟网卡vnet驱动程序
    ram_flash驱动
    S3C2440 nor_flash驱动程序
    Java 打印* 三角形
    Java系列学习说明
    java案例1,打印hello java
    zabbixproxy安装
    python鉴黄程序
    mssql发布订阅事项
  • 原文地址:https://www.cnblogs.com/chenyang920/p/8387713.html
Copyright © 2011-2022 走看看