English 中文(简体)
彩色谱仪操作——用另一个图像作为面罩对图像适用彩色
原标题:Bufferedimage bitmask operations - apply a color to an image using another image as a mask

I have two BufferedImage objects, src and dest. Both are grayscale, src is 1bpc (B&W basically), and dest could really be any sort of color space/bpc/etc.

我需要能够在<代码>dest上提取一些颜色,作为比照数。 基本上,如果<条码>src中的pixel为黑色,则应当改成色体。 但是,如果<条码>src中的pixel是白色的,那么<条码>dest就应当单独保留。

如果是这样的话,我也正在引力行动中进行细致的变革。

Graphics2D g = dest.createGraphics();
// do something here???
g.drawImage(src, transform, null);
g.dispose();

In a pure B&W world this would involve a simple | of the pixel values together - but it seems like there s probably a correct way to do this using image operations.

Gutins本能说,这是一个确定合成和某种甲型六氯环己烷的问题,但我对使用什么价值感到完全损失。 在图2d的更先进方面,我几乎没有经验——任何要点都会受到高度赞赏。

最佳回答

I think that I ve come up with an effective solution using this article

这当然是高效率的,尽管我不相信是否遵循最佳做法:

BufferedImage dest; // input
BufferedImage src; // input

...

byte[] r = new byte[]{(byte)0,(byte)255}; // 255=black, we could set it to some other gray component as desired
byte[] g = new byte[]{(byte)0,(byte)255};
byte[] b = new byte[]{(byte)0,(byte)255};
byte[] a = new byte[]{(byte)255,(byte)0};
IndexColorModel bitmaskColorModel = new IndexColorModel(1, 2, r, g, b, a);

BufferedImage masked = new BufferedImage(bitmaskColorModel, src.getRaster(), false, null);

Graphics2D g = dest.createGraphics();
g.drawImage(masked, transform, null);
g.dispose();
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签