---
title: "imageJ入门2"
author: "还是你更好"
date: "2009-02-06T11:45:22Z"
tags: []
categories: ["非技术"]
slug: "imagej-2"
draft: false
lastmod: "2009-02-06T13:48:03Z"
id: 323914
url: "https://6ke.iteye.com/blog/323914"
---

今天有时间写个例子了.参见<http://2003274226.iteye.com/blog/323564>的图,ij会打开一个recoder的窗口,你对图片的任何操作,都会被这个recoder记录.如:

```java

saveAs("Jpeg", "D:\\aaaa.jpg");
run("Size...", "width=60 height=60 constrain interpolate");
saveAs("Jpeg", "D:\\aaaa.jpg");
close();
run("Size...", "width=12 height=12 constrain interpolate");
//setTool(0);
close();
close();
close();
run("Size...");
run("Canvas Size...");
run("Size...", "width=30 height=30 constrain interpolate");
close();

```

下面给个简单的例子.之前当然要把ij.jar导入lib里,这些不多说.

```java

       IJ.open("D:\\e.jpg");
       IJ.run("Size...", "width=30 height=30 constrain interpolate");
       IJ.save("D:\\ee.jpg");

```

原图是120X120的圖片,執行run("Size...", "width=30 height=30 constrain interpolate");後保存就縮小了,成30X30的.這裡面的縮小算法你不用管.同樣,如果你想對篾片有其他操作,放大,銳化等等,你都不用管是怎么做的,一條run命令搞定.而這些命令是如何來?ij自帶一個軟件,你可以先在上面打開一張圖片進行操作,比如進行銳化操作,recorder會記錄這個命令.這些同樣可参见<http://2003274226.iteye.com/blog/323564>.