python+matlab 3通道图像加横纵坐标和0-255色标

目的:对输入的3通道图像进行可视化操作实现加横纵坐标和色标操作,其中色标范围是0-255,但是不对输入图像做灰度化处理。

步骤:

1、用python中的convert方法将3通道转成1通道

python代码:

def RGBtoGray(path):
    files = os.listdir(path)
    for file in files:
        imgpath = path + '/' + file
        # print(imgpath)
        #
        im = Image.open(imgpath).convert('L')
        #resize将图像像素转换成自己需要的像素大小
        img = im.resize((100, 100))
        dirpath = newpath
        # file_name, file_extend = os.path.splitext(files)
        # dst = os.path.join(os.path.abspath(dirpath), file_name + '.jpg')
        img.save('D:/code/welddata/testimage/test/1.jpg')
if __name__ == "__main__":
    RGBtoGray(path)

2、用matlab画1通道灰度图的色标图

Matlab代码:

clear all
I = imread('E:\Matlab2019a\bin\tu01.png'); #读入图片
 I = im2double(I);
 dataRangeI = [min(I(:)) max(I(:))]
 h = [1 2 1; 0 0 0; -1 -2 -1];
 J = imfilter(I,h);
 dataRangeJ = [min(J(:)) max(J(:))]
 imshow(J,[])
 colormap(gray);       #坐标图
colorbar;             #加色标
caxis([0,255]);
axis('on');

代码结果:

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值