Image from Gradient and Magnitude

Hello, with imgradient I can compute the magnitude and direction of an image's gradient. Is it also possible to somehow compute an image from magnitude and direction?
I basically have a 2d matrix with a linear ramp in a certain direction, and I want to increase the slope of this ramp, so that the direction stays the same, but the values increase faster.
The overall offset does not matter.
Thank you very much!

Answers (1)

Image Analyst
Image Analyst on 6 Jul 2014
Sounds like it should be theoretically possible to rebuild the image, but I'm not sure how. I take it that you somehow have the gradient image, not from imgradient() but from some other source - otherwise you'd already have the original image and you would not need to recreate it.

5 Comments

Hello Image Analyst, I already have the image with a linear ramp, and I want to create another image with the ramp in the same direction, but a steeper slope. So I use imgradient to get the initial gradient.
Simply multiply your original image by a scalar.
image2 = image2 * someValue;
If the values would go above 255 and your image is uint8, then cast the image to double before multiplying.
image2 = double(image1) * someValue;
Even if they don't exceed 255 you might have to cast to double - then cast to uint8 after the multiplication.
image2 = uint8(double(image1) * someValue);
T
T on 6 Jul 2014
Edited: T on 6 Jul 2014
unfortunately this won't help, the slope is slowly changing, only the direction is constant. and I want to add a constant slope with same direction over the entire image. If I scale, the added slope is not constant over the image
My method just amplified all slopes. If you have a particular ramp that you want then you have to add or multiply that ramp image by the original image
output = image1 .* rampImage;
or
output = image1 + rampImage;
Yes, but I don't know how to create the ramp image. I know the direction the ramp needs to have from the gradient of image1.

Sign in to comment.

Asked:

T
T
on 6 Jul 2014

Commented:

T
T
on 6 Jul 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!