• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6630
  • Last Modified:

How does Brightness,Contrast, Hue, Saturation, actually work?

I have attached the file of image processing application for iphone. Each of the cases(Brightness , Hue , Saturation..etc) are calling some other functions can some one please explain to me  how they are doing the required process.  Which algorithm or how the brightness or hue or saturation actually changing in this following application. They are in the function viewDidLoad in the file ViewController.m.
I have included all the files including the header files. So all the functions it is calling are present in the given project folder.

Link to File:
http://www.4shared.com/file/UKhLlkZE/ImageProcess_3.html
pass : imageprocess
0
sanghai45
Asked:
sanghai45
  • 6
  • 5
5 Solutions
 
tbrent77Commented:
Brightness and contrast control the non color functions of a image. That is,..brightness is how bright and contrast is a ratio of full bright to full dark and can vary how dark a contrast between bright and dark really are.

Hue is the color temperture or tinge and can adjust, say,..  pink, to get darker till it becomes almost red... leave this one alone in most cases as the manufacturer has this preset...  Saturation is the intensity of the color/s itself.

Most of these settings are fixed with the exception of brightness and possibly contrast on things like a mobile phone.  Try using the default settings in your program and test only one of them at a time.  If you don't know what the default settings are, look at the help files and use the center range of adjustment.  If you can't find the range of numbers then just make a guess and test it to see what happens. Most compilers or run time debuggers will tell you if the range is correct or not.
0
 
pgnatyukCommented:
I do not have any example for iPhone.
I've tried to download the zip-file you posted - I cannot open this zip-file on Mac.

Here is few useful links - it is about Windows and C#, but the algorithms will be the same in Objective-C too.

Adjusting The Contrast Of An Image.
http://www.bobpowell.net/image_contrast.htm

CodeProject. Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters
http://www.codeproject.com/KB/GDI-plus/csharpgraphicfilters11.aspx

In the last CodeProject article you will find a very simple explanation about the brightness and contrast (other filters) too.
0
 
pgnatyukCommented:
Same in C++
CodeProject. Image Processing Using GDI+
http://www.codeproject.com/KB/graphics/ImageProcessing.aspx

It is again about Windows programming, but the algorithms are the same.

C++ works fine on iPhone.
HBITMAP, other GDI calls should be replaced.

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
sanghai45Author Commented:
kindly use the software called "The Unarchiver" for extracting the file.
I asked two of my friends to test it on macs and it works.
password : imageprocess

link for The Unarchiver : http://www.apple.com/downloads/macosx/system_disk_utilities/theunarchiver.html
0
 
pgnatyukCommented:
Thanks. I've downloaded. It is an iPhone application that uses OpenGL - simple and standard OpenGL code if in image.c file. It is a very nice implementation. This code can be re-used in any application and for any platform.

The main functions are:
static void brightness(V2fT2f *quad, float t)      // t [0..2]
static void contrast(V2fT2f *quad, float t)      // t [0..2]
static void greyscale(V2fT2f *quad, float t)      // t = 1 for standard perceptual weighting
static void extrapolate(V2fT2f *quad, float t)      // t [0..2]
static void blur(V2fT2f *quad, float t)      // t = 1

This is the Apple source code. The theory you get here: http://ati.amd.com/developer/gdc/GDC2005_SATEnvironmentReflections.pdf

OpenGL in Mac Reference Library:
http://developer.apple.com/mac/library/DOCUMENTATION/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_intro/opengl_intro.html
http://www.apple.com/macosx/what-is-macosx/graphics-media.html

I'd begin from these simple articles on CodeProject:
CodeProject. Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters
http://www.codeproject.com/KB/GDI-plus/csharpgraphicfilters11.aspx

CodeProject. Image Processing Using GDI+
http://www.codeproject.com/KB/graphics/ImageProcessing.aspx

Then with OpenGL on Mac.
0
 
sanghai45Author Commented:
Could you please look into the file viewcontroller.m and explain to me how exactly each of those are working... Like how the brightness is actually being changed... And so on..
0
 
pgnatyukCommented:
Ok. Let's try.

1. Let's beging from the MainViewController. In the implementation file you can find few classical implementations - how to choose an image file on iPhone, and then how to scale it. This last function is implemented in:
- (UIImage *)scaleAndRotateImage:(UIImage *)image

Everything used in this method is pure Cocoa - detect the image size, detect the screen size, use Affine transformation to scale the image correctly and draw it on the graphic context.

Maybe this is a central method in this program.

2. ViewController. You probably asked about these few buttons Brightness, Contrast, Saturation, Hue and Sharpness.
The image is:
UIImage *imageValue;
It is a static variable in this file together with io (UIImageView*).

These buttons are drawn on the screen.
You can save and send an image via email.

This file does not contain the algorithms.

3. The important code is in folder Classes. The functions that are interesting for you are in imaging.c file.
These files are taken from Apple dev resources. These are C and OpenGL code as I've told you. All work is done by OpenGL and I have nothing to comment here - these are the standard algorithms and I have posted the links explained the theory. These function like brightness are called from drawGL function as filters applied to the texture. This drawGL method is called from drawView from EAGLView class. There is "mode" variable in the parameters - this variable sets which filter will be used - brightness, contrast, etc. After the rendering (applying a filter to the texture) the image (the pixels) are copied onto the image that will be shown on the screen. The size of the result image is hardcoded (320x480).

It is a small and interesting program.




0
 
sanghai45Author Commented:
Dude we are gettting problem while applying brightness , hue, saturation etc... I mean to say if i took image nd applied brightness now if i want to change contrast and go on tab of contrast at the same time . My image gets refresh ie. Original image. Conclusion, I am not able to change brightness , contrast , hue at the same time on one image. If i changed brightness i  need to save it first then i need to upload the changed image then i can go for contrast etc...

ANother problem is when i upload the changed image or any image from library it gets stretched.


Can u  help us out with this two problems....Urgently please

Thanks
0
 
pgnatyukCommented:
>>to change brightness , contrast , hue at the same time on one image
In the code you posted all these algorithms were in the different functions. It is not a trivial thing to combine all of them in one function. If you need to call three function one by one, you can modify that code - make new functions -almost the same as you have but without the refreshing. Add new button to that app and make the change under this button.
 
0
 
sanghai45Author Commented:
Can u edit it and give it please...the problem is we have project presentation tmrw and we need to do other documents stuff also . i know this is something i m givng my project work to u but it will be very helpful to us if u will do the needful ..if u cant then also its fine for your precious time u have helped us a lot...

THanks a lot ...


0
 
pgnatyukCommented:
Sorry, if you wish you can ask a related question here or ask a freelancer. Unfortunately, I'm busy with my own projects and in the evening I have no power to get in into this project.
0
 
sanghai45Author Commented:
Its fine dude ...thanks ..for ur precious time
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now