none
How to make a color curve adjasment? RRS feed

Answers

  • This is the behaviour I wanted, if you do not provide a value for x = 0, x=0 and y=0 is assumed.

    If you want to have the output from the picture above of the other program, add a point for x=0 with a curve tension of 0: (btw: this is a demo for creating cardinal-spline color curves, not a clone of an existing program)

    Regards,

      Thorsten

    • Marked as answer by Mrs. Maro Friday, May 18, 2012 9:42 PM
    Friday, May 18, 2012 9:19 PM

All replies

  • Typically, when a program is made available like this, it's for a developer to use. As a developer, you should be able to go in and figure out how he's doing it and 'correct' the issue. a lot of open code projects don't work 'out of the box' and are shared tools used to help other developers get where they need to be.

    Perhaps asking Thorsten Gudera for help if you are unwilling or unable to attempt to fix it yourself?


    Stephen J Whiteley

    Thursday, May 17, 2012 12:39 PM
    Moderator
  • If I'm able to fix it I wouldnit need help... I couldn't fix C# codes Im just a bigenner in C#.
    Thursday, May 17, 2012 12:47 PM
  • Hi,

    when only some color values are that much out of the expected range, there might be an overflow issue...

    Regards,

      Thorsten


    Thursday, May 17, 2012 5:22 PM
  • Hi,

    I can reproduce this here, so you dont need to post the image, I will fix that, but it will take some time (it's (at least) the parsing of the path-points, especially when more points have the same x- value...). because I have some other things to do before. I'll be back when updating the file on skydrive (maybe tomorrow, but maybe I can do it tonight)

    Regards,

      Thorsten


    Thursday, May 17, 2012 5:43 PM
  • This is the Image but not that the problem because I used many images and test it in photoshop and in your project it gives the same issue, and i used the same values but it gives different colors.


    • Edited by Mrs. Maro Thursday, May 17, 2012 6:27 PM (I Removed the Image )
    Thursday, May 17, 2012 5:57 PM
  • And thanks Mr. Thorsten Gudera for helping...
    Thursday, May 17, 2012 6:04 PM
  • Hi,

    I made a very quick fix for the issue with selecting the y-value for the first pathpoints x value, but this might still change a bit. The updated file: (this might still change, for I will inspect it closer tonight)

    https://skydrive.live.com/redir.aspx?cid=d5e5bd21dbf5e4e9&resid=D5E5BD21DBF5E4E9!2262&parid=D5E5BD21DBF5E4E9!1450&authkey=!

    Regards,

      Thorsten

    Thursday, May 17, 2012 6:07 PM
  • Hi,

    is this a self taken image?

    Regards,

      Thorsten


    Thursday, May 17, 2012 6:18 PM
  • Thanks very much, if you tell me where is the issue maybe I can fix it because it need much time to be fixed, I have time just tell me where the values that must be changed, and the much problem that I don't know how this curve work this is why I needed some help (I'am new to Graphics and Image Editing). But Realy Thank You Mr. Thorsten Gudera ...
    Thursday, May 17, 2012 6:32 PM
  • Ok,

    the problem is in the method ReadPath in the frmGradColors3. It might be, that the pathpoints contain mor than one point for an x value. Until the last update, I always took the first of these points, but when there are for instance two points with x = 0, y = 0 and x = 0, y= 255 the first point - the point thats used in further processing - isnt the right one (as in that case you want to map the x value 0 to y=255 to invert the color), so I now changed that to take the one with the highest y-value. I dont know, if this always concerns only the first point, I will check that but I think, it will now work correctly.

    Regards,

      Thorsten 

    Thursday, May 17, 2012 7:50 PM
  • Ok, how it works:

    The main thing is to adjust the colors by mapping a new value to an arrayindex in an array that will be used as a lookuptable. So we setup an array of type byte with a length of 256 (1 "slot" for every possible value). In unchanged state the value at each field is the value of the index. So red[0] has a value of 0, red[127] a value of 127 and so on.
    This array (and two more for the other two color chanells) are then passed to a c# function that does the actual image-prrocessing.
    Basicallly this function takes the value for each colorchannel at each pixel and looks what's in the corresponding array at the current-color-channel-value index. It then assigns the value of the arrayfield at this index to the colorchannel at the given pixel.

    So what in the UI happens is the mapping of the new values to the arrays. If you add a point to the panel by right-clicking, the array that holds the points is new dimensioned (to store the additional point also) and all current points are listed. Now we create a curve through all these points and look at each x-value from 0 to 255 what y value is present (for all value-possibilities for this color channel).
    This y-value is then assigned to the array at the index that corresponds with the x-value. This process is done by using a GraphicsPath and adding the curve to that path. Now the path is flattend, so its a polyline with small segments.
    These PathPoints and the lines in between are now processed to get (y-)values for each x-value we need.
    This is done in the ReadPath method that contained the error when inverting the picture by the curve.

    Generally the code is old and not very readable (I wrote it while learning c# and vb), maybe you should rewrite the UI-part to get a clearer code layout, but the way to get the values will likely be the same. Maybe you could draw the curve in a nearestneighbor interpolated bitmap and "parse" this bitmap for not-transparent-colors, but I think this would be a step back to what we actually do. The function to process the image is not needed to change IMHO

    Regards,

      Thorsten



    Thursday, May 17, 2012 11:15 PM
  • Hello ,

      I spent more than 4 hours trying to solve the problem, the code is too hard and long, I maybe some one can help me. I found a project but it edit only RGB not seprated curves. but MR. Thorsten's project can give more options, and a list of points for each color....


    • Edited by Mrs. Maro Friday, May 18, 2012 11:01 AM
    Friday, May 18, 2012 10:48 AM
  • Hi, did you download the version I posted yesterday to skydrive (link above)? It should resolve the issue with the wrong colored pixels when setting the curve to invert the picture.

    I created a pic that shows the issue extremely clear: [In the old version, a value-mapping of x=0 to y=0 was always added because the first appearance of the first x-value in the PathPoints was being added, now the one with the highest y-value is put to the array for the first point]

    (before update)

    (after update)

    Regards,

      Thorsten



    Friday, May 18, 2012 5:43 PM
  • Hi, Yes I download it, sure I'am bothering you, but many values isn't correct:

    In PhotoShop:

    The updated Project:


    • Edited by Mrs. Maro Friday, May 18, 2012 6:49 PM
    Friday, May 18, 2012 6:42 PM
  • This is the behaviour I wanted, if you do not provide a value for x = 0, x=0 and y=0 is assumed.

    If you want to have the output from the picture above of the other program, add a point for x=0 with a curve tension of 0: (btw: this is a demo for creating cardinal-spline color curves, not a clone of an existing program)

    Regards,

      Thorsten

    • Marked as answer by Mrs. Maro Friday, May 18, 2012 9:42 PM
    Friday, May 18, 2012 9:19 PM
  • Thank you, I missed that,

    I will try to make it  draw a curve by defualt and the curve tens =0, but the other curves tens = selected tens..

    like this one:

    • Edited by Mrs. Maro Friday, May 18, 2012 9:50 PM
    Friday, May 18, 2012 9:46 PM
  • for doing something like that, you will have to edit the adding to the path in the method DrawPic. I only add *one* curve in that method, so all is of the same tension. This is something I never needed, so I didnt add that to the program.

    Regards,

      Thorsten

    Friday, May 18, 2012 9:59 PM
  • You still can achieve something like that by using two (ore more) passes of adjusting the colors and leaving parts of the curve at the default x to y mapping.

    I actually never compared my tool to any other program when writing it, I just needed the possibility to adjust colors by curves in a graphical represenation, and I thought, that it would be a good exercise for learning (as I mentioned, I wrote it a long time ago, when I was learning).

    If you really want to make each segment's tension editable, create a class that represents a segment with start, end, curvetype (enum) and tension properties and then add the segments (for each channel) to the path instead of the whole point-arrays.

    Regards,

      Thorsten

    Edit: Ok, you persuaded me to update that old code a bit, so here's a very first new version (which is not complete, just a first view to see where it will go)

    https://skydrive.live.com/redir.aspx?cid=d5e5bd21dbf5e4e9&resid=D5E5BD21DBF5E4E9!2292&parid=D5E5BD21DBF5E4E9!1479&authkey=!



    Friday, May 18, 2012 10:21 PM
  • I Thank You, sure I bothered you, but after all we should test our projects and know what its problem by comparing it with profissional programs.

    I start learning VB just few months ago and starts learning C# few weeks ago, My teacher told me if I wan't some thing just use this forum... And I realized that I shouldn't depend only on my teacher, and I should ask experts to know more about programming.

      Thanks,  Mrs. Maro

    Saturday, May 19, 2012 3:21 PM
  • I Thank You, sure I bothered you, but after all we should test our projects and know what its problem by comparing it with profissional programs.

    ...

    I disagree. I try to develop my Ideas and make those programs work as I want them to, not to work them as other programs do (which would probably lead to cloning the other program what I do not like). And for the Color-curves tool, I simply dont see that there's a problem (except for the script-like spaghetti code), It works as I expected. It does what I want it to: It shows a way of how you could - lazily - adjust colors by using cardinal spline curves with the help of gdi+ and the GraphicsPath. Other programs may use different curve types, calculate them in different ways etc.

    I will also keep that program as it is, because I like the ideas I had when writing it. Of course I could calculate the curve "by hand" - the cardinal splines are relatively "friendly" (concerning maths) and are also relatively easy to represent by using bezier segments [You only need the first derivative and there's only one question to answer: Which interval to differanciate]. But I wanted to show this convenient way. If you dont like it, change it (for the sources are available) or use the other programs you mentioned. If I once will port that to WPF, I will have to go the other way and *use* the bezier splines...

    [Also I'm a hobbyist programmer with no professional requirements...]

    Regards,

      Thorsten


    Saturday, May 19, 2012 5:29 PM