本文整理汇总了Java中org.opencv.imgcodecs.Imgcodecs.imread方法的典型用法代码示例。如果您正苦于以下问题:Java Imgcodecs.imread方法的具体用法?Java Imgcodecs.imread怎么用?Java Imgcodecs.imread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opencv.imgcodecs.Imgcodecs
的用法示例。
在下文中一共展示了Imgcodecs.imread方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadImage
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void loadImage(String saveRoute, List<Mat> matLists, List<Integer> labels) {
File saveRoot = new File(saveRoute);
if(!saveRoot.exists()) {
LOG.info("图片保存路径--" + saveRoute + "--不存在");
return;
}
if(!saveRoot.isDirectory()) {
LOG.info("图片路径--" + saveRoute+ "--不是一个文件夹");
return;
}
File[] procImages = saveRoot.listFiles(new ImageFileFilter());
for(int i = 0; i < procImages.length; i ++) {
LOG.info("加载图片:" + procImages[i].getAbsolutePath());
Mat m = Imgcodecs.imread(procImages[i].getAbsolutePath(), Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
matLists.add(m);
labels.add(Integer.parseInt(procImages[i].getName().split("_")[0]));
}
}
示例2: enhanceImageContrast
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void enhanceImageContrast() {
Mat source = Imgcodecs.imread("GrayScaleParrot.png",
Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
Mat destination = new Mat(source.rows(), source.cols(), source.type());
Imgproc.equalizeHist(source, destination);
Imgcodecs.imwrite("enhancedParrot.jpg", destination);
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:8,代码来源:OpenCVNonMavenExamples.java
示例3: processStillImage
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
private void processStillImage() {
Mat mat = Imgcodecs.imread("fly.bmp");
for (int c = 0; c < mat.width() / 2; c++) {
for (int r = 0; r < mat.height() / 2; r++) {
double color[] = mat.get(r, c);
color[0] = 255;
mat.put(r, c, color);
//System.out.printf("(%d, %d) = %s\n", r, c, Arrays.toString(color));
}
}
Imgcodecs.imwrite("fly_new.bmp", mat);
Mat gray = new Mat();
Imgproc.cvtColor(mat, gray, Imgproc.COLOR_RGB2GRAY);
Imgcodecs.imwrite("fly_gray.bmp", gray);
}
示例4: denoise
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void denoise() {
String imgInPath = "captchaExample.jpg";
imgInPath = "MyCaptcha.PNG";
imgInPath = "blurredtext.jpg";
String imgOutPath = "captchaNoiseRemovedExample.png";
imgOutPath = "MyNoiseRemovedCaptcha.PNG";
Mat image = Imgcodecs.imread(imgInPath);
Mat out = new Mat();
Mat tmp = new Mat();
Mat kernel = new Mat(new Size(3, 3), CvType.CV_8UC1, new Scalar(255));
// Mat kernel = new Mat(image.size(), CvType.CV_8UC1, new Scalar(255));
Imgproc.morphologyEx(image, tmp, Imgproc.MORPH_OPEN, kernel);
Imgproc.morphologyEx(tmp, out, Imgproc.MORPH_CLOSE, kernel);
Imgcodecs.imwrite(imgOutPath, out);
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:17,代码来源:OpenCVNonMavenExamples.java
示例5: run
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void run() {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
String base = "C:/Books in Progress/Java for Data Science/Chapter 10/OpenCVExamples/src/resources";
CascadeClassifier faceDetector =
new CascadeClassifier(base + "/lbpcascade_frontalface.xml");
Mat image = Imgcodecs.imread(base + "/images.jpg");
MatOfRect faceVectors = new MatOfRect();
faceDetector.detectMultiScale(image, faceVectors);
out.println(faceVectors.toArray().length + " faces found");
for (Rect rect : faceVectors.toArray()) {
Imgproc.rectangle(image, new Point(rect.x, rect.y),
new Point(rect.x + rect.width, rect.y + rect.height),
new Scalar(0, 255, 0));
}
Imgcodecs.imwrite("faceDetection.png", image);
}
示例6: processRawImage
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
/**
*
* @Title: processRawImage
* @Description: 处理原始图片, 对用户上传的人脸图片进行预处理
* @param rawFacePathDir 原始图像的保存根路径(根文件有所有单人的图像,单人图像以注册的手机号为文件夹存储)
* @param processedSavePathDir 处理后要保存的根路径
* @return
* boolean
*/
public static boolean processRawImage(String rawFacePathDir, String processedSavePathDir, int faceLabel) {
File rawRoot = new File(rawFacePathDir);
// rawRoot不存在或者不是一个文件夹,返回false
if(!rawRoot.exists() || !rawRoot.isDirectory())
return false;
//如果输出路径不存在,则创建文件夹
File outRoot = new File(processedSavePathDir);
if(!outRoot.exists()) {
outRoot.mkdirs();
}
File[] rawImages = rawRoot.listFiles(new ImageFileFilter());
// 用预处理根路径的文件夹名字作为用户预处理图片的标签
for(int i = 0; i < rawImages.length; i ++) {
Mat m = Imgcodecs.imread(rawImages[i].getAbsolutePath(), Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
LOG.info("正在处理:" + rawImages[i]);
Mat preproc = rawProcessedFace(m);
if(preproc != null) {
String filename = processedSavePathDir + File.separator + faceLabel +"_" + (i+1) +".jpg";
Imgcodecs.imwrite(filename, preproc);
}
}
return true;
}
示例7: processarAlgoritmo
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void processarAlgoritmo(String diretorioImagem, String nomeDaImagem) {
Mat imagemOriginal = Imgcodecs.imread(diretorioImagem, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
Mat imagemTratada = new Mat(imagemOriginal.rows(), imagemOriginal.cols(), imagemOriginal.type());
imagemTratada = imagemOriginal;
Imgproc.adaptiveThreshold(imagemOriginal, imagemTratada, 500, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 11, 1);
Imgcodecs.imwrite(System.getProperty("user.home") + "/Desktop/" + nomeDaImagem + ".png", imagemTratada);
}
示例8: main
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void main(String[] args) {
String opencvDLL = "G:/java/JavaProjectRelease/classchecks/src/main/webapp/WEB-INF/dll/x64/opencv_java320.dll";
System.load(opencvDLL);
Mat src = Imgcodecs.imread("e:/classchecks/paper/zoudongjun.jpg");//e:/classchecks/Test/13.jpg G:/C++/images/flower3.jpg
int scaledWidth = 320;
float scale = src.cols() / (float) scaledWidth;
Mat resizeMat = resize(src, scale, scaledWidth);
Imgcodecs.imwrite("e:/classchecks/paper/resize.jpg", resizeMat);
/*grayEqualizeHist(src);*/
//unevenLightCompensate(src, 32);
ImageGui.imshow(resizeMat, "src");
}
示例9: enhanceImageBrightness
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void enhanceImageBrightness() {
double alpha = 1; // Change to 2 for more brightness
double beta = 50;
String fileName = "cat.jpg";
Mat source = Imgcodecs.imread("cat.jpg");
Mat destination = new Mat(source.rows(), source.cols(),
source.type());
source.convertTo(destination, -1, 1, 50);
Imgcodecs.imwrite("brighterCat.jpg", destination);
}
示例10: main
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// 根据系统架构载入dll
final Properties props = System.getProperties();
final String bits = String.valueOf(props.get("sun.arch.data.model"));
System.out.println("System Architecture: " + bits + " bits System");
if (Integer.parseInt(bits) == 64) {
System.loadLibrary("opencv_java330_64");
} else {
System.loadLibrary("opencv_java330_86");
}
// Scanner inputKey = new Scanner(System.in);
// 欢迎
System.out.println("Welcome running Classified Project Argus");
// 载入主封面和初始化主控窗口
final Mat cover = Imgcodecs.imread(System.getProperty("user.dir") + "/cover.jpg");
CentralControl.imshow(cover, "SpotSpotter");
final List<String> oldlist = new ArrayList<String>();
pilot(oldlist);
// while (true) {
// Time.waitFor(100);
// if (CentralControl.hasWorkDir) {
// if (CentralControl.ok2Proceed) {
// FileListener.autoDeepScan(CentralControl.algoIndex);
// }
// }
// }
// System.exit(0);
}
示例11: processarAlgoritmo
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public void processarAlgoritmo(String diretorioImagem, String nomeDaImagem) {
Mat imagemOpenCV = Imgcodecs.imread(diretorioImagem, Imgcodecs.CV_LOAD_IMAGE_COLOR);
Mat imagemOpenCVProcessada = this.processarImagem(imagemOpenCV);
Imgcodecs.imwrite(System.getProperty("user.home") + "/Desktop/" + nomeDaImagem + ".png", imagemOpenCVProcessada);
}
示例12: Pythagoras_G
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static Mat Pythagoras_G(String input) {
// public static void main(String[] args) {
// TODO �Զ����ɵķ������
// String input =
// "D:/workspace/SpotSpotter/src/pers/zylo117/spotspotter/image/1.jpg";
// String output =
// "D:/workspace/SpotSpotter/src/pers/zylo117/spotspotter/image/output1.jpg";
final int roiWidth = 20;
final int roiHeight = 20;
final int ulx = 206;
final int uly = 182;
final int urx = 302;
final int ury = 182;
final int llx = 206;
final int lly = 326;
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat src = Imgcodecs.imread(input);
// Upper-Left corner
src = CornerDetector.corners(src, ulx, uly, roiWidth, roiHeight, 10, false);
// �����Ž�
upperLeft_optimus();
// Imgproc.circle(CornerDetector.srcROI, rel_ulPoint, 4, new Scalar(255, 255,
// 0), 2);
abs_ulPoint = new org.opencv.core.Point(ulx + rel_ulPoint.x, uly + rel_ulPoint.y);
// Upper-Right corner
src = CornerDetector.corners(src, urx, ury, roiWidth, roiHeight, 15, false);
// �����Ž�
upperRight_optimus();
// Imgproc.circle(CornerDetector.srcROI, rel_urPoint, 4, new Scalar(255, 255,
// 0), 2);
abs_urPoint = new org.opencv.core.Point(urx + rel_urPoint.x, ury + rel_urPoint.y);
// Lower-Left corner
src = CornerDetector.corners(src, llx, lly, roiWidth, roiHeight, 15, false);
// �����Ž�
lowerLeft_optimus();
// Imgproc.circle(CornerDetector.srcROI, rel_llPoint, 4, new Scalar(255, 255,
// 0), 2);
abs_llPoint = new org.opencv.core.Point(llx + rel_llPoint.x, lly + rel_llPoint.y);
// Lower-Right corner
// abs_lrPoint =FourthCorner.fourthPoint(abs_ulPoint, abs_urPoint, abs_llPoint);
ROIOutput.abs_lrPoint = FourthCorner.fourthPoint(ROIOutput.abs_ulPoint, ROIOutput.abs_urPoint,
ROIOutput.abs_llPoint);
// Imgcodecs.imwrite(output, src);
return src;
}
示例13: abrirImagem
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public static Mat abrirImagem(String path) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
return Imgcodecs.imread(path, IMREAD_COLOR);
}
示例14: abrirImagem
import org.opencv.imgcodecs.Imgcodecs; //导入方法依赖的package包/类
public Mat abrirImagem(String path) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
return Imgcodecs.imread(path, IMREAD_COLOR);
}