第08章imagej插件编程docxWord文档下载推荐.docx
- 文档编号:14948637
- 上传时间:2022-10-26
- 格式:DOCX
- 页数:8
- 大小:107.88KB
第08章imagej插件编程docxWord文档下载推荐.docx
《第08章imagej插件编程docxWord文档下载推荐.docx》由会员分享,可在线阅读,更多相关《第08章imagej插件编程docxWord文档下载推荐.docx(8页珍藏版)》请在冰豆网上搜索。
Plugin插件
件
■插件
不需要图像作为输入的插件可以实现Plugin接口。
Plugin接口的定义为:
•publicinterfacePlugin{
•publicvoidrun(Stringargs);
•}
—个实现Plugin接口的自定义插件:
•publicclassMy_PluginimplementsPlugin{
•publicvoidrun(Stringarg)(
•IJ.showMessage(,,My_Plugin,'
"
Helloworld!
"
);
•J
需要对图像进行处理的插件可以实现PluglnFilter接口。
PluglnFilter接口的定义为:
•publicinterfacePluglnFilter{
•publicintsetup(Stringarg,ImagePlusimp);
•publicvoidrun(lmageProcessorip);
•}
publicclassMy_Filter_PluginimplementsPluglnFilter{ImagePlusimp;
publicintsetup(Stringarg,ImagePlusimp){this.imp=imp;
returnD0ES_8G;
}
publicvoidrun(ImageProcessorip){ImagePluscopy=newlmagePlus(ncopy,f,ip);
copy.show();
i需要用户界面的插件可以继承PluglnFrame类。
PluglnFrame类的定义为:
kJ
•publicclassPluglnFrameextendsjava.awt.FrameimplementsPlugin{}
publicclassMy_Plugin_FrameextendsPluglnFrame{
Panelpanel;
publicMy_Plugin_Frame(){super("
Plugin_Frame”);
panel=newPanel();
panel.setLayout(newGridLayout(l,3,5,5));
addButton("
Stepln);
addButtonfStep2”);
Step3n);
add(panel);
pack();
GUI.center(this);
setVisible(true);
1
privatevoidaddButton(Stringlabel){Buttonbtn=newButton(label);
panel.add(btn);
ij.plugin.frame
图像类型
说明
字段名
8位灰度图像
雪个像素由byte类型表示z有256个灰度级。
GRAY8
8位彩色索引图像
每个像素的颜色由颜色查找表确定。
C0L0R.256
丄6位灰度图像
每个像素有65535个灰度级。
GRAY16
RGB彩色图像
每个像素由红、绿、蓝三个颜色分量组成,每个颜色分量取值为0-
255O
C0L0R.RGB
32位浮点图像
每个像素由float或者double类型的变量表示。
GRAY32
ImageJ
ImagePlus^^示
图像。
ImageProcessor类表示图像处理器。
ByteProcessor类
ShortProcessor类
ImageProcessor
AueuiSer
IMAGEPROCESSOR类
类的名称
含义
ByteProcessor
处理8位的灰度图像和彩色索引图像
ShortProcessor
处理16位的灰度图像
ColorProcessor
处理32位整数的彩色RGB图像
FloatProcessor
处理32位浮点数的灰度图像
BinaryProcessor
处理黑白图像
像素读写
读像素:
•publicabstractObjectgetPixels();
写像素:
•publicabstractvoidsetPixels(Objectpixels);
bytepix=pixelsfidx];
//错误!
(灰度值范围为[0,255])
10000001
末位加久
40111mi)
idx
401111110)
intpix=pixels[idx]=<
L27(错误!
)
byte[]pixels=(byte[])ip.getPixels();
//获取像素数组的引用intidx=10;
intpix=pixels[idx]&
Oxff;
……//对Pix进行相应的处理
pix=255-pix;
//取反
pixels[idx]=(byte)pix;
//翕制类型转换
字节型
削妾舍弃高24位,只留
下低8位
shortilIS妲^^shorti师8對5禺曲融Mb牆謂鞠「弧1鹅
intidx=10;
?
?
;
……//对pix进行相应的处理
十进制
33068
pixels[idx]=(short)pix;
//强制类型转换
111111*********1
1000000100101100
0000000000000000
ffffffff11111111
00000000000000001000000100101100
short[]
oooooooooooooooo
削妾舍弃高16^,只留
下低16位
■
intred=10;
intgreen=100;
intblue=129;
00000000
00001010
01100100
AlphaiEfi
red通道
green通道
blueilil
RGB图像中的一个像素由32位整型组成
int[]MS(int⑴删耶切
intidx=10;
intred=(int)(pixels[i]&
OxffOOOO)>
>
16;
//获取红色分量
intgreen=(int)(pixels[i]&
OxOOffOO)>
8;
//获取绿色分量intblue=(int)(pixels[i]&
OxOOOOff);
//获取蓝色分量
mTnn
OxOOffOOOO
//获取红色分量intgreen=(int)(pixels[i]&
//获取蓝色分量……//连行相应处理
pixels[i]=(red&
Oxff)«
16)+((green&
8)+(blue&
Oxff);
&
iTiTmi
OxOOOOOOff
16
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 08 imagej 插件 编程 docx