我在Java中使用Marvin Image Processing Framework,我正在努力扩展图像。它只是制作一个黑色方块,你能看出我做错了吗?设定的阈值正在运行。
package com.example.marvin;
import marvin.image.MarvinImage;
import marvin.io.MarvinImageIO;
import marvin.plugin.MarvinImagePlugin;
import marvin.util.MarvinPluginLoader;
public class Imageprocess {
public static void main (String[] args) {
MarvinImage image = MarvinImageIO
.loadImage("/Users/unknown1/Desktop/images.jpeg");
MarvinImagePlugin thresholdplugin = MarvinPluginLoader
.loadImagePlugin("org.marvinproject.image.color.thresholding.jar");
MarvinImagePlugin scaleplugin = MarvinPluginLoader
.loadImagePlugin("org.marvinproject.image.transform.scale.jar");
thresholdplugin.setAttribute("threshold", 85);
thresholdplugin.process(image, image);
scaleplugin.setAttribute("newWidth", 50);
scaleplugin.setAttribute("newHeight", 37);
scaleplugin.process(image, image);
image.update();
MarvinImageIO.saveImage(image, "/Users/unknown1/Desktop/images1.jpeg");
}
}
答案 0 :(得分:1)
它使用最新版本的Marvin!
import marvin.image.MarvinImage;
import marvin.io.MarvinImageIO;
import static marvin.MarvinPluginCollection.*;
public class Imageprocess {
public static void main (String[] args) {
MarvinImage image = MarvinImageIO.loadImage("./res/chamaleon.jpg");
thresholding(image, 85);
scale(image.clone(), image, 50, 37);
MarvinImageIO.saveImage(image, "./res/chamaleon_scaled.jpg");
}
}
答案 1 :(得分:0)
你需要在每个过程之后做image.update();
然后你得到以下代码:
...
thresholdplugin.setAttribute("threshold", 85);
thresholdplugin.process(image, image);
image.update();
scaleplugin.setAttribute("newWidth", 50);
scaleplugin.setAttribute("newHeight", 37);
scaleplugin.process(image, image);
image.update();
...
当然,最好使用最新版本的插件