ImageJでのパンシャープン処理の方法
- 位置合わせを行ったPa画像とMu画像を用意する。
- 両方の画像ともHSI(HSB)チャンネルに変換する。
- MuのIチャンネルをPaのチャンネルと入れ替える。
- MuのHSIをRGBに戻す。
- パンシャープン処理完了
ImageJでのモザイク処理(画像結合)
ImageJはプラグインを追加することで、モザイク処理を行うことが可能となる。
- まず、必要なプラグインは以下の2つ。以下をDLし解凍する。TurboRegが画像の位置合わせの処理をしている模様。
- ImageJのプラグインフォルダに解凍した*.jarファイルを入れる。
- ImageJを起動する。
- プラグインメニューから「MosaicJ」が選択できるので、選択起動する。
- モザイク処理を行いたい画像を複数選択する。
- 手動で位置を合わせる。(自動化はできない)
- メニューからCreate Mosaic?を選択する。
お試しとして、本ページにアップしてある画像「sample1」と「sample2」をモザイク処理してみると良い。
ImageJでマクロを作る
良くppmからjpgに変換するので、マクロを作成した。
「ppm2jpg.ijm」とかの適当な名前で保存し、ImageJのフォルダにある「Macro」フォルダの中に置く。
ImageJを起動し、「Plugins>Macros」を選択し、「Install」を選び、作成したmacroファイルを選ぶとリストに表示される。
saveAsjpg();
function saveAsjpg()
{
path = getDirectory("image");
name = getInfo("image.filename");
saveAs("jpg", path+replace(name, ".ppm", ".jpg"));
}
特定のフォルダ内の画像を自動で処理するテンプレ
input = getDirectory("Input directory");
output = getDirectory("Output directory");
Dialog.create("File type");
Dialog.addString("File suffix: ", ".ppm", 5);
Dialog.show();
suffix = Dialog.getString();
processFolder(input);
function processFolder(input)
{
list = getFileList(input);
for (i = 0; i < list.length; i++)
{
if(File.isDirectory(list[i]))
processFolder("" + input + list[i]);
if(endsWith(list[i], suffix))
processFile(input, output, list[i]);
}
}
function processFile(input, output, file) {
// do the processing here by replacing
// the following two lines by your own code
print("Processing: " + input + file);
open(input+file);
print("Saving to: " + output);
saveAsjpg(input,output,file);
close();
}
function saveAsjpg(input,output,name)
{
// 変換処理
//path = getDirectory("image");
//name = getInfo("image.filename");
saveAs("jpg", output+replace(name, ".ppm", ".jpg"));
}
最終更新:2019年03月09日 01:07