MAC OSX 安装 Color summarizer 与 Circos

IMAGE COLOR SUMMARIZER 是一个颜色分析工具,这个工具
可以快速分析出一张图片的前X种颜色颜色(最多10种)的占比,以及各种维度如 RGB、HSB、CMYK等。
效果如下

MAC OSX 安装 Color summarizer 与 Circos_第1张图片
image.png

下载

wget http://mkweb.bcgsc.ca/color-summarizer/download/colorsummarizer-0.77.tgz
mkdir -p ~/Software/colorsummarizer

cd ~/Software/colorsummarizer
tar xvfz colorsummarizer-0.77.tgz
ln -s colorsummarizer-0.77 current
export PATH=~/software/colorsummarizer/current/bin:$PATH
. ~/.bash_profile

验证

# usage
> colorsummarizer -help

# man page
> colorsummarizer -man

如果出现下方错误

/bin/env: bad interpreter: No such file or directory

可以修改 bin/colorsummarizer 首行
首先 ln env

sudo su
cd /bin
ln -s /usr/bin/env env
exit

将文件首行

#!/bin/env perl

改为

#!/usr/bin/env perl

或验证 Perl 的地址

which perl
/usr/local/bin/perl

将首行改为

#!/usr/bin/env perl

如果出现类似下方的错误,那么可能需要安装 Perl 以及一些模块

Can't locate Some::Module.pm in @INC ...

使用 cpan 命令安装 perl 提示缺失的模块

> cpan
> install Some::Module

如果安装过程一切正常就说明成功了,再次验证即可,不过正常还需要安装它所有依赖的 Circos

“ circos是使用Perl语言编写,采用GPL许可,可以运行于任何有Perl语言解释器的操作系统(如 Windows, Mac OS X, Linux 及其他类UNIX系统)的免费软件。它可以轻易地根据纯文本的配置文件,将用户的输入数据转化为像素图片(PNG)或矢量图片(SVG)。

所处理的可视化图形


MAC OSX 安装 Color summarizer 与 Circos_第2张图片
image.png

安装

下载circos, 完成后将文件移至 ~/Software/circos/:

wget http://circos.ca/distribution/circos-0.69-6.tgz
mkdir -p ~/Software/circos
mv ./circos-0.69-6.tgz ~/Software/circos

配置 PATH

cd ~/Software/circos
tar xvfz circos-0.69-6.tgz
ln -s circos-0.69-6 current
export PATH=~/Software/circos/current/bin:$PATH
. ~/.bash_profile

安装依赖库

可用 brew 快速安装 libpng、libjpeg、freetype、libgd

brew install libpng
brew install libjpeg
brew install freetype
brew install libgd

如果没有 brew 也可以编译安装,或先安装 Home brew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

install libpng

mkdir ~/Software/src/libpng
cd ~/Software/src/libpng
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.26.tar.gz
tar zxfv libpng-1.6.26.tar.gz
rm libpng-1.6.26.tar.gz
ln -s libpng-1.6.26 current 
cd current
./configure
make
sudo make install 

install libjpeg

mkdir ~/Software/src/libjpeg
cd ~/Software/src/libjpeg
wget http://www.ijg.org/files/jpegsrc.v9b.tar.gz
tar zxfv jpegsrc.v9b.tar.gz
rm *.gz
ln -s jpeg-9b current
cd current
./configure
make
sudo make install

install freetype

mkdir ~/Software/src/freetype
cd ~/Software/src/freetype
wget http://circos.ca/distribution/lib/freetype-2.4.0.tar.gz
tar zxfv freetype-2.4.0.tar.gz && rm freetype-2.4.0.tar.gz
ln -s freetype-2.4.0 current
cd current 
./configure
make
sudo make install

** install libgd **

. ~/.bash_profile
mkdir ~/Software/src/libgd
cd ~/Software/src/libgd
wget https://github.com/libgd/libgd/releases/download/gd-2.2.3/libgd-2.2.3.tar.gz
tar xfvz ./libgd-2.2.3.tar.gz
ln -s libgd-2.2.3/ current
cd current
./configure --without-fontconfig --disable-werror --prefix=/opt/local
make
sudo make install
sudo cpan
cpan[1]> install GD
cpan[2]> exit
gdlib-config --all
## gdlib-config: warning: this script is deprecated; please use the pkg-config file instead.
## GD library  2.2.3
## includedir: /usr/local/include
## cflags:     -I/usr/local/include
## ldflags:     -L/usr/X11/lib
## libs:          -lz  -L/usr/local/lib -lpng16  -L/usr/local/lib -lfreetype   -lfontconfig   -ljpeg   -lXpm -liconv
## libdir:     /usr/local/lib
## features:   GD_GIF GD_GIFANIM GD_OPENPOLYGON GD_ZLIB GD_PNG GD_FREETYPE GD_FONTCONFIG GD_JPEG GD_XPM 

验证,并安装缺失的 perl module

circos -modules
## ok       1.29 Carp
## ok       0.36 Clone
## missing            Config::General
## ok       3.62 Cwd
## ok      2.154 Data::Dumper
## ok       2.52 Digest::MD5
## ok       2.84 File::Basename
## ok       3.62 File::Spec::Functions
## ok     0.2304 File::Temp
## ok       1.51 FindBin
## missing            Font::TTF::Font
## ok            GD
## missing            GD::Polyline
## ok       2.39 Getopt::Long
## ok       1.16 IO::File
## ok       0.33 List::MoreUtils
## ok       1.38 List::Util
## missing            Math::Bezier
## ...

安装缺失的模块

sudo cpan
cpan[1]> install Config::General
cpan[2]> install Font::TTF::Font
cpan[3]> install Math::Bezier
cpan[4]> install Math::VecStat
cpan[5]> install Readonly
cpan[6]> install SVG
cpan[7]> install Set::IntSpan
cpan[8]> install Statistics::Basic
cpan[9]> install Text::Format
...
cpan[*]> exit

运行实例,测试是否安装成功**

cd ~/Software/circos/current/example
./run
open circos.png

成功后打开图片将能看到

image.png

如果示例出现问题,可能是 GD 安装问题,手动安装

wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.51.tar.gz
tar xfvz ./GD-2.51.tar.gz
cd GD-2.51/
perl Makefile.PL 
make
sudo make install

Circos 安装成功后,验证 Color summarizer

➜  colorsummarizer-0.77 ./bin/colorsummarizer -help

Usage:
      # output format XML, text or JSON
      colorsummarizer -image img/ferns-100.jpg -xml
      colorsummarizer -image img/ferns-100.jpg -text
      colorsummarizer -image img/ferns-100.jpg -json

      # get image size
      colorsummarizer -image img/ferns-100.jpg -info

      # process all images in a directory
      colorsummarizer -dir "images/*jpg"

      # resize input image
      colorsummarizer -image img/ferns-100.jpg -width 50 -text
…

根据帮助提示的命令可以验证颜色工具的提取功能

colorsummarizer -image img/ferns-100.jpg -json
{
   "data" : {
      "color0" : "#4B8C2B",
      "color1" : "#5EA735",
      "color2" : "#7ECC4E",
      "color3" : "#336D19"
   }
}

成功!

可以开心的去处理图片色值的可视化数据了。

你可能感兴趣的:(MAC OSX 安装 Color summarizer 与 Circos)