从图像中提取红色通道

时间:2012-03-29 06:10:45

标签: rgb imagick

我有一张图片说' X' (RGB)我想使用Imagick获取RED频道的图像 我尝试引用http://www.imagemagick.org/Usage/quantize

1 个答案:

答案 0 :(得分:0)

您需要的命令位于https://www.imagemagick.org/Usage/color_basics/#separate处的ImageMagick文档中:

  

分离频道图像

     

分离出各个颜色通道的最简单方法是使用“ -separate”运算符将每个通道的当前内容提取为灰度图像。

constructor(){
  super();
  this.state = {
    sessionChecks: 0,
    currentUser: null
  };
  this.renderRoute = this.renderRoute.bind(this);
  this.checkActiveUser = this.checkActiveUser.bind(this);
  this.authSession = firebase.auth();
}

checkActiveUser() {
  const { sessionChecks } = this.state;
  const loggedUser = this.authSession.currentUser;
  // check for the loggedUser
  if ( !loggedUser && sessionChecks < 3 ) {
    setTimeout(
      () => {
        this.setState({ sessionChecks: ( sessionChecks + 1 ) });
        this.checkActiveUser();
      },
      500
    );
  } else if ( loggedUser ){
    // in this check there is a logged user
    // update the component's state, this will force a render
    // and the corresponding component will be rendered
    this.setState({ currentUser: true });
  }
}

renderRoute(component){
  // if the current user is null means we're still checking
  // so we check strictly true
  if ( this.state.currentUser === true ) {
    // the check is complete and there's an active user, show the component
    return component;
  } else if ( !this.state.currentUser ) {
    // the check is complete and there isn't an active user
    // show a login component 
    return <LoginComponent />;
  }
}

render(){
  return <div>
    <Route path="/" exact render={ () => this.renderRoute(<DashboardComponent />) } />
    <Route path="/tags" render={ () => this.renderRoute(<TagsComponent />) } />
    <Route path="/posts" render={ () => this.renderRoute(<PostsComponent />) } />
    <Route path="/programs" render={ () => this.renderRoute(<ProgramsComponent />) } />
  </div>;
}
     

Rose ==> Rose Red Rose Green Rose Blue

(在这些示例中,convert rose: -channel R -separate separate_red.gif convert rose: -channel G -separate separate_green.gif convert rose: -channel B -separate separate_blue.gif 参数使用玫瑰的内置小图像作为输入。)