473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

brightness adjusting on black & white images vb.net

I'm trying to implement some code in vb.net to allow the user to
adjust the brightness or contrast on an image (through the use of a
slider) that is already black & white in the bitmap. I have tried
to use the colormatrix and even down to the pixel using GetPixel and
SetPixel in system.drawing, but I'm really not up on using gdi+ and
haven't really gotten anywhere. I've seen some examples for VB6, but
I need vb.net.

I know that all the pixels are either 255 or 0 already since its black
and white, but if you are adusting the brightness, how do you decide
which pixels to turn white or black based on how much the user wants
to brighten/darken. I've got code to read & set each pixel, but I
just dont know what to use to decide what to set the new pixel to.

If you someone could post some code or point me to a good example that
explains whats going on, I would be most appreciative.

Thanks,
Mark
Nov 21 '05 #1
7 10784
The GDI+ FAQ has articles on this. Search bobpowell.net for ColorMatrix

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo.com> wrote in message
news:tv********************************@4ax.com...
I'm trying to implement some code in vb.net to allow the user to
adjust the brightness or contrast on an image (through the use of a
slider) that is already black & white in the bitmap. I have tried
to use the colormatrix and even down to the pixel using GetPixel and
SetPixel in system.drawing, but I'm really not up on using gdi+ and
haven't really gotten anywhere. I've seen some examples for VB6, but
I need vb.net.

I know that all the pixels are either 255 or 0 already since its black
and white, but if you are adusting the brightness, how do you decide
which pixels to turn white or black based on how much the user wants
to brighten/darken. I've got code to read & set each pixel, but I
just dont know what to use to decide what to set the new pixel to.

If you someone could post some code or point me to a good example that
explains whats going on, I would be most appreciative.

Thanks,
Mark

Nov 21 '05 #2
ma*****@yahoo.com wrote:
I'm trying to implement some code in vb.net to allow the user to
adjust the brightness or contrast on an image (through the use of a
slider) that is already black & white in the bitmap. I have tried
to use the colormatrix and even down to the pixel using GetPixel and
SetPixel in system.drawing, but I'm really not up on using gdi+ and
haven't really gotten anywhere. I've seen some examples for VB6, but
I need vb.net.

I know that all the pixels are either 255 or 0 already since its black
and white, but if you are adusting the brightness, how do you decide
which pixels to turn white or black based on how much the user wants
to brighten/darken. I've got code to read & set each pixel, but I
just dont know what to use to decide what to set the new pixel to.

If you someone could post some code or point me to a good example that
explains whats going on, I would be most appreciative.

Thanks,
Mark


If your values are at 0 or 255 you've got maximum contrast. You can't
decrease contrast for just a few pixels since there would be no way to
determine what pixels should remain white/black and what pixels should
turn some shade of grey. You could only decrease the contrast by
bringing the 0 and 255 values closer together, but don't expect some
gradient to appear.

--
Rinze van Huizen
C-Services Holland b.v.
Nov 21 '05 #3
So you can use the ColorMatrix to adjust images even if they are
already black and white ?

On Thu, 6 Jan 2005 10:55:00 +0100, "Bob Powell [MVP]"
<bob@_spamkiller_bobpowell.net> wrote:
The GDI+ FAQ has articles on this. Search bobpowell.net for ColorMatrix


Nov 21 '05 #4
Of course. The matrix doesn't care what values the RGB elements are or if
they're the same, which is all a grayscale is, equal R, G and B.

You can still change the brightness and contrast using the matrix. You can't
put saturation back in though. That's like trying to put the air back in a
burst balloon.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo.com> wrote in message
news:f7********************************@4ax.com...
So you can use the ColorMatrix to adjust images even if they are
already black and white ?

On Thu, 6 Jan 2005 10:55:00 +0100, "Bob Powell [MVP]"
<bob@_spamkiller_bobpowell.net> wrote:
The GDI+ FAQ has articles on this. Search bobpowell.net for ColorMatrix

Nov 21 '05 #5
Thanks Bob.

I took your example of adjusting the contrast (the one with
ImageContrast as the namespace) and ran against one of my test images.
The problem was the image was able to get darker, but never got any
lighter (even when moving the trackbar all the way over). Let me
explain what I'm doing. The images we display are coming out of a
check scanner for our customers. We allow them to rescan them at
lighter/darker contrast values, but that forces them to go through the
scanner again which is not a real fast device. So what I wanted to do
is let them adjust the original image directly on the screen through
the use of a trackbar and not require them to go through the scanner
again.

The images are coming out of the scanner in a 1bpp indexed pixel format
- black/white ?

Any ideas why it wouldn't get any darker. Is there a better way to do
it.

Many thanks.

Nov 21 '05 #6
I guess the reason is because you're altering the original image, not a copy
of it.

You need to copy the original to the new setting every time, don't change an
image and then try to adjust *its* contrast / brightness later. It's a
classic degradation problem.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks Bob.

I took your example of adjusting the contrast (the one with
ImageContrast as the namespace) and ran against one of my test images.
The problem was the image was able to get darker, but never got any
lighter (even when moving the trackbar all the way over). Let me
explain what I'm doing. The images we display are coming out of a
check scanner for our customers. We allow them to rescan them at
lighter/darker contrast values, but that forces them to go through the
scanner again which is not a real fast device. So what I wanted to do
is let them adjust the original image directly on the screen through
the use of a trackbar and not require them to go through the scanner
again.

The images are coming out of the scanner in a 1bpp indexed pixel format
- black/white ?

Any ideas why it wouldn't get any darker. Is there a better way to do
it.

Many thanks.

Nov 21 '05 #7
That makes sense. Yea, I am applying the new user settings to the
"already adjusted" image, when I should be going back to the original
each time.

I'll try it when I get in the office. Thanks.
Bob Powell [MVP] wrote:
I guess the reason is because you're altering the original image, not a copy of it.

You need to copy the original to the new setting every time, don't change an image and then try to adjust *its* contrast / brightness later. It's a classic degradation problem.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

<ma*****@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks Bob.

I took your example of adjusting the contrast (the one with
ImageContrast as the namespace) and ran against one of my test images. The problem was the image was able to get darker, but never got any
lighter (even when moving the trackbar all the way over). Let me
explain what I'm doing. The images we display are coming out of a
check scanner for our customers. We allow them to rescan them at
lighter/darker contrast values, but that forces them to go through the scanner again which is not a real fast device. So what I wanted to do is let them adjust the original image directly on the screen through the use of a trackbar and not require them to go through the scanner again.

The images are coming out of the scanner in a 1bpp indexed pixel format - black/white ?

Any ideas why it wouldn't get any darker. Is there a better way to do it.

Many thanks.


Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Amy | last post by:
Hi, I have written a program using JAI for a project I am doing which can be used to adjust the brightness of an image. It all works fine but I now need to write it all up and am not entirely...
3
by: ACaunter | last post by:
Hi there, I was wondering how i could have a slider bar or something on my ASP.Net page to control the image quality.. like change it's sharpness, brightness, and contrast?? is that possible??...
4
by: Greg | last post by:
I'm guessing the problem I'm having has something to do with Master Pages or DetailsView because the exact same code works fine on a page without a Master Page and DetailsView controls. The...
1
by: Sandy | last post by:
Dear Pythonic People, I recently discovered SciTE (1.68) as a programming editor, and I find it just beautiful. Small, fast, elegant and beautiful. I particularly like syntax highlighting...
1
by: retheeshnewage | last post by:
I have a doubt in php.I wrote a php program to convert colour Images to balck & white.It is working fine with JPEG files and PNG files.When it comes to GIF files I am not getting the colour...
1
by: Thorsten Kleinweber | last post by:
Hello, I did some first steps in programming a site for a friend and have some questions concerning web design. The site is http://www.stevanez-juls.de: 1. On my tft display (with low...
3
by: Muddasir | last post by:
hi all i need to upload an image and if that image is coloured i need to convert it to black and white image ... till now i only uploaded images ... simple.. have no idea how to do this...
1
by: metaphysics | last post by:
I can't seem to find this anywhere on the web, so I figured I'd post the question here. I'd like to be able to define an image class in CSS to make all posted images black and white. For example, I...
3
by: bmahussain | last post by:
Anybody having javascript coding for adjusting brightness and contrast of an image using slider control. If yes, then kindly forward the same. regards, hussain.
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.