如何从绿色图像中获取原始图像 [英] how to get original image from green image

查看:89
本文介绍了如何从绿色图像中获取原始图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,我已经将图像转换为绿色部分,这意味着我已经使用滤色镜概念并将图像转换为绿色图像,现在我想将绿色图像转换为原始图像.当我将进度条移动到原始位置时,更改进度条的图像颜色会改变.因此,该怎么做请帮帮我.谢谢

hi friends I have converted an image to green part means i have used color filter concept and converted an image to green image now i want to convert green image to again original image.for example i want to do such that there is a progress bar when i move the prgress bar color of image is get changed when i put progress bar to original possion original color gets back.so how to do this please help me.Thanks

推荐答案

我想您的意思是您希望通过某种运行时可调控件(例如TrackBar)来控制绿色"的相对强度.

无论如何,恕我直言,无论您使用此处建议的任何解决方案类型,都应始终保留原始全彩文件的原始"副本!
如果要在代码中执行此操作,那么几乎可以肯定,您将要研究相对较新的" ColorMatrix工具[ ^ ] ...和...使用C#和.NET 3.5进行透明控件" [ ^ ].

快速而肮脏"的解决方案是创建两个位图:从原始图像开始:在GIMP或PhotoShop中打开它,然后...例如在PhotoShop中...使用图像/调整/饱和度"对话框,选中着色"按钮,然后使图像非常暗绿色.

显然,在您的项目中:您需要将绿色图像"放置在原始全色之上,然后使用TrackBar或其他方法更改其不透明度值,以控制它的绿色"程度. br/>
但是,棘手的问题是:第二张(绿色的)图像应该在哪个容器中还是第一张全彩色的图像?

由于PictureBox不直接支持不透明度,请参见以下讨论以实现该目的:"C#PictureBox的不透明度" [ ^ ].

有关使用面板实现透明度的信息,请参见以下文章:请参见鲍勃·鲍威尔的旧文章,但不错,它是:[ ^ ]

对于与UserControls一起使用的透明度/不透明度:与上述链接的相同CP资源将为您提供一些指导.另请参见此MSDN讨论:[ ^ ].

最后,虽然我总体上反对将表单放在...内部或总体上置于"其他表单之上的想法;您可以将绿化"图片放置在其自己的无边界形式(如BackGroundImage)中:然后:在主形式中(使用TrackBar):

1.创建第二个Form的新实例.

2.将第二个窗体的所有者属性"设置为主窗体...如果将第二个窗体添加到主窗体的ControlCollection中,则独立"不透明度将不适用于第二个窗体!

3.在主窗体"加载事件中执行正确的操作,以将第二个绿色窗体准确地定位在第一个彩色窗体上.然后,您的Main Form Load事件可能看起来像这样:
I think you mean you want to control the relative intensity of "green" with some kind of run-time adjustable control, like a TrackBar.

In any case, imho, you shoud always keep a "virgin" copy of the original full-color file around, whether you use any of the types of solutions suggested here !

If you are going to do this in code, then you are almost certainly going to want to examine the "relatively newer" ColorMatrix facility[^], and the ImageAttributes Class[^].

Or you may want to use what are now older techniques involving the Paint operation and LockBits: literally looping through every pixel and modifying its alpha value.

There are articles on CP showing how to accomplish this, and I strongly suggest you search CP for them. Such as:[^] ... and ... "Making Transparent Controls with C# and .NET 3.5"[^].

A "quick and dirty" solution would be to create two bit-maps: start with the original image: open it in GIMP or PhotoShop, then ... for example in PhotoShop ... use the Image/Adjustments/Saturation dialog, check the "colorize" button, and then make the image very dark greenish.

Obviously, in your project: you''ll want to put the "greened image" on top of the original full-color, and then alter its opacity value with a TrackBar, or whatever, to control how "green" it is.

But, the tricky question is: in what Container should the second (greened) image be ! Or, the first full-color image ?

Since a PictureBox does not support opacity directly: see this discussion for how to achieve that: "C# Opacity Of Picturebox"[^].

For using Panels to achieve transparency, see this: see Bob Powell''s old, but good, article: [^]

For using transparency/opacity with UserControls: the same CP resources linked to above will give you some guidelines. Also see this MSDN discussion:[^].

Finally, while I am generally against the idea of putting Forms inside ... or "over" other Forms in general; you could put the "greened" picture in its own borderless Form (as BackGroundImage): then: in the Main Form (with the TrackBar):

1. create a new instance of the second Form.

2. set the ''Owner Property of the second Form to the Main Form ... "independent" opacity will NOT work for the second Form if you add it to the ControlCollection of the Main Form !

3. Do the right thing in Main Form load event to position the second greened form exactly over the first colored Form. Your Main Form Load event might then look like this:
// define a class scoped variable for the second Form
private Form2 f2;
//
Form1_Load(object sender, EventArgs e)
 {
     f2 = new Form2();
     f2.Owner = this;
     f2.Show();
     // note the need to translate co-ordinates here
     f2.Location = PointToScreen(ColorPictureBox.Location);
     f2.BringToFront();
 }

然后,您可以使用Main FormTrackBar的Change Value来设置绿色表单的不透明度:

Then you can use the Main FormTrackBar change Value to set the opacity of the greened form:

private void trackBar1_Scroll(object sender, EventArgs e)
{
    // note the need to use Convert.ToDouble here !
    f2.Opacity = Convert.ToDouble(trackBar1.Value) / 100.0;
}

这可以工作...但是...

您可能需要在这里进行认真评估的问题是:您是否要构建一个一次性的解决方案,以使图片变绿",请尽快:或者,您要掌握一套照片吗?将来可能普遍用于各种位图操作的技术?

祝你好运,比尔

This will work ... but ...

The question you might want to really evaluate carefully here is: do you want build a one-off solution for making a picture "greened," asap: or, do you want to master a set of techniques that could be generally useful in the future for doing all kinds of bitmap manipulation ?

good luck, best, Bill


这篇关于如何从绿色图像中获取原始图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆