| |
 |
|
| Computers Forum Index » Computer - Graphics (Algorithms) » Choose correct pixel (Intertesting problem)... |
|
Page 1 of 1 |
|
| Author |
Message |
| Pankaj... |
Posted: Wed Oct 21, 2009 2:21 am |
|
|
|
Guest
|
I have a problem when two 2-D images are overlapping in a area. Then I
have to draw both the images side by side in such a way that they
seems to be merging. I am drawing first image and then second image on
same memory buffer. Now my problem is how to determine which pixel to
draw (old Image/new Image). As to show merging I don't want to
overwrite all the pixels of old image with new image. I have four
color to play with.(ForeColor, BackColor, Old Memory Buffer Color, New
Memory Buffer Color). All the images are color and using grayScale
Alpha blending on edges so we will have lots of different color pixel
in one image specially on edges. I hope some of graphics designer must
have face this problem. Please let me know the approach or some algo
to decide. Currently I am using one method to check the new memory
color and old memory color distance from foreground color and printing
the closer one. Also I did same with background color and printing
which is far from background color. These are failing some time
specially if I choose foreground and background color same.
(Condition :-Main part of both Picture must be using foreground color
as this is character text and that part should not be overwritten.).
Thanks in advance. |
|
|
| Back to top |
|
|
|
| mxology... |
Posted: Wed Oct 21, 2009 7:51 am |
|
|
|
Guest
|
On Oct 21, 7:21 am, Pankaj <milopanka... at (no spam) gmail.com> wrote:
Quote: I have a problem when two 2-D images are overlapping in a area. Then I
have to draw both the images side by side in such a way that they
seems to be merging. I am drawing first image and then second image on
same memory buffer. Now my problem is how to determine which pixel to
draw (old Image/new Image). As to show merging I don't want to
overwrite all the pixels of old image with new image. I have four
color to play with.(ForeColor, BackColor, Old Memory Buffer Color, New
Memory Buffer Color). All the images are color and using grayScale
Alpha blending on edges so we will have lots of different color pixel
in one image specially on edges. I hope some of graphics designer must
have face this problem. Please let me know the approach or some algo
to decide. Currently I am using one method to check the new memory
color and old memory color distance from foreground color and printing
the closer one. Also I did same with background color and printing
which is far from background color. These are failing some time
specially if I choose foreground and background color same.
(Condition :-Main part of both Picture must be using foreground color
as this is character text and that part should not be overwritten.).
Thanks in advance.
I once needed this sort of smooth merging of images, and I used an
approach of varying alpha value to merge the two edges (regardless of
foreground or background colors).
Suppose the 2 images are A and B, merging from left and right
respectively. Now, if the edge has x overlapping pixels, it would
mean, the last x pixel-columns of A and first x pixel-columns of B
would be overlapping.
Each of these x pixel-columns should have some fraction of A and rest
part of B. This fraction would be the alpha value that would
monotonously differ from 0 to x overlapping pixel-columns.
This would mean that the overlapping pixels closest to A would have
major portion of A, and those away from it would have more of image B
color values.
Excuse me if that wasn't what you asked for.
regards,
Ankur |
|
|
| Back to top |
|
|
|
| Pankaj... |
Posted: Wed Oct 21, 2009 10:39 am |
|
|
|
Guest
|
On Oct 21, 12:51 pm, mxology <mathur.an... at (no spam) gmail.com> wrote:
Quote: On Oct 21, 7:21 am, Pankaj <milopanka... at (no spam) gmail.com> wrote:
I have a problem when two 2-D images are overlapping in a area. Then I
have to draw both the images side by side in such a way that they
seems to be merging. I am drawing first image and then second image on
same memory buffer. Now my problem is how to determine whichpixelto
draw (old Image/new Image). As to show merging I don't want to
overwrite all the pixels of old image with new image. I have four
color to play with.(ForeColor, BackColor, Old Memory Buffer Color, New
Memory Buffer Color). All the images are color and using grayScale
Alpha blending on edges so we will have lots of different colorpixel
in one image specially on edges. I hope some of graphics designer must
have face this problem. Please let me know the approach or some algo
to decide. Currently I am using one method to check the new memory
color and old memory color distance from foreground color and printing
the closer one. Also I did same with background color and printing
which is far from background color. These are failing some time
specially if Ichooseforeground and background color same.
(Condition :-Main part of both Picture must be using foreground color
as this is character text and that part should not be overwritten.).
Thanks in advance.
I once needed this sort of smooth merging of images, and I used an
approach of varying alpha value to merge the two edges (regardless of
foreground or background colors).
Suppose the 2 images are A and B, merging from left and right
respectively. Now, if the edge has x overlapping pixels, it would
mean, the last xpixel-columns of A and first xpixel-columns of B
would be overlapping.
Each of these xpixel-columns should have some fraction of A and rest
part of B. This fraction would be the alpha value that would
monotonously differ from 0 to x overlappingpixel-columns.
This would mean that the overlapping pixels closest to A would have
major portion of A, and those away from it would have more of image B
color values.
Excuse me if that wasn't what you asked for.
regards,
Ankur- Hide quoted text -
- Show quoted text -
Thanks Ankur,
But this approach will not help me. I have few cases when alpha is
zero. So I need to use the color details only and most of my problem
is for same foreground and background color. I have tried using
shifting of both color as well. |
|
|
| Back to top |
|
|
|
| Pankaj... |
Posted: Wed Oct 21, 2009 10:40 am |
|
|
|
Guest
|
On Oct 21, 12:51 pm, mxology <mathur.an... at (no spam) gmail.com> wrote:
Quote: On Oct 21, 7:21 am, Pankaj <milopanka... at (no spam) gmail.com> wrote:
I have a problem when two 2-D images are overlapping in a area. Then I
have to draw both the images side by side in such a way that they
seems to be merging. I am drawing first image and then second image on
same memory buffer. Now my problem is how to determine whichpixelto
draw (old Image/new Image). As to show merging I don't want to
overwrite all the pixels of old image with new image. I have four
color to play with.(ForeColor, BackColor, Old Memory Buffer Color, New
Memory Buffer Color). All the images are color and using grayScale
Alpha blending on edges so we will have lots of different colorpixel
in one image specially on edges. I hope some of graphics designer must
have face this problem. Please let me know the approach or some algo
to decide. Currently I am using one method to check the new memory
color and old memory color distance from foreground color and printing
the closer one. Also I did same with background color and printing
which is far from background color. These are failing some time
specially if Ichooseforeground and background color same.
(Condition :-Main part of both Picture must be using foreground color
as this is character text and that part should not be overwritten.).
Thanks in advance.
I once needed this sort of smooth merging of images, and I used an
approach of varying alpha value to merge the two edges (regardless of
foreground or background colors).
Suppose the 2 images are A and B, merging from left and right
respectively. Now, if the edge has x overlapping pixels, it would
mean, the last xpixel-columns of A and first xpixel-columns of B
would be overlapping.
Each of these xpixel-columns should have some fraction of A and rest
part of B. This fraction would be the alpha value that would
monotonously differ from 0 to x overlappingpixel-columns.
This would mean that the overlapping pixels closest to A would have
major portion of A, and those away from it would have more of image B
color values.
Excuse me if that wasn't what you asked for.
regards,
Ankur- Hide quoted text -
- Show quoted text -
Thanks Ankur. But I have cases when I don't have alpha information in
images. So I need to use the color details only. |
|
|
| Back to top |
|
|
|
| Daniel Pitts... |
Posted: Fri Oct 23, 2009 12:45 am |
|
|
|
Guest
|
Pankaj wrote:
Quote: On Oct 21, 12:51 pm, mxology <mathur.an... at (no spam) gmail.com> wrote:
On Oct 21, 7:21 am, Pankaj <milopanka... at (no spam) gmail.com> wrote:
I have a problem when two 2-D images are overlapping in a area. Then I
have to draw both the images side by side in such a way that they
seems to be merging. I am drawing first image and then second image on
same memory buffer. Now my problem is how to determine whichpixelto
draw (old Image/new Image). As to show merging I don't want to
overwrite all the pixels of old image with new image. I have four
color to play with.(ForeColor, BackColor, Old Memory Buffer Color, New
Memory Buffer Color). All the images are color and using grayScale
Alpha blending on edges so we will have lots of different colorpixel
in one image specially on edges. I hope some of graphics designer must
have face this problem. Please let me know the approach or some algo
to decide. Currently I am using one method to check the new memory
color and old memory color distance from foreground color and printing
the closer one. Also I did same with background color and printing
which is far from background color. These are failing some time
specially if Ichooseforeground and background color same.
(Condition :-Main part of both Picture must be using foreground color
as this is character text and that part should not be overwritten.).
Thanks in advance.
I once needed this sort of smooth merging of images, and I used an
approach of varying alpha value to merge the two edges (regardless of
foreground or background colors).
Suppose the 2 images are A and B, merging from left and right
respectively. Now, if the edge has x overlapping pixels, it would
mean, the last xpixel-columns of A and first xpixel-columns of B
would be overlapping.
Each of these xpixel-columns should have some fraction of A and rest
part of B. This fraction would be the alpha value that would
monotonously differ from 0 to x overlappingpixel-columns.
This would mean that the overlapping pixels closest to A would have
major portion of A, and those away from it would have more of image B
color values.
Excuse me if that wasn't what you asked for.
regards,
Ankur- Hide quoted text -
- Show quoted text -
Thanks Ankur. But I have cases when I don't have alpha information in
images. So I need to use the color details only.
I think his point is that you would *set* the alpha value yourself,
based on the distance from the edge of the images.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/> |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Sun Nov 22, 2009 4:46 am
|
|