我在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");
}
}
最佳答案
它使用最新版本的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");
}
}
关于java - 用马文缩放图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34369234/