• Matlab图片改颜色通道不改名存储


    反反复复因为用matlab处理图像,包括读取、提取命名、用不同通道表示、存储等一系列操作,下面简单总结一下遇到的一些问题。

    我这次处理的问题是将一个放了多张图片的文件夹里所有RGB彩图转为YCbCr的Y通道图存在新的文件夹下,同时不改变图片的名字。

    代码如下:

     1 clear;
     2 clc
     3 
     4 folder = 'Training_Data/Train';  %图片存储的路径
     5 savepath = 'trainNew/';      %目标存储位置
     6 filepaths = dir(fullfile(folder,'*.bmp'));
     7 
     8 for i = 1 : length(filepaths)
     9     
    10     image = imread(fullfile(folder,filepaths(i).name));
    11     image = rgb2ycbcr(image);      %RGB转YCbCr
    12     image = im2double(image(:, :, 1));
    13     imageName=filepaths(i).name;    %获取原图片的名字字符串
    14     saveStr= [savepath imageName];   %设置存储路径+命名
    15     imwrite(image, saveStr);
    16     
    17 end


    完成后在新的文件夹下就可以看到保存好的Y通道的图啦~

    Everything will be ok in the end. If it is not ok then it is not the end.
  • 相关阅读:
    spring学习(一)IOC&AOP
    MongoDB 写入数据的安全性
    MongoDB MapReduce
    MongoDB 原子操作
    MongoDB 文档间的关系
    MongoDB Java
    MongoDB 持久化
    MongoDB 聚合函数 aggregate
    MongoDB 索引
    MongoDB 文档操作
  • 原文地址:https://www.cnblogs.com/shirleytian/p/6108527.html
Copyright © 2020-2023  润新知