how to get gradient of an image

5 Ansichten (letzte 30 Tage)
Rawan hamdi
Rawan hamdi am 25 Mär. 2013
Verschoben: DGM am 29 Dez. 2023
hi im having a hyperspectral image and im trying to get the gradient operators of the horizontal and vertical directions but i can't any help? Thanks

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Apr. 2013
for band = 1 : size(X,3)
[GX(:,:,band), GY(:,:,band)] = gradient(X(:,:,band));
end
Note you get out two matrices the same size as the original.
  9 Kommentare
Rawan hamdi
Rawan hamdi am 9 Apr. 2013
Thank you very much.
i have a question, how can i obtain the cost function :
u = arg min(||g-u||).^2 + lambda.R(u) where the term "(||g-u||).^2" is the data fidelity term between the original clean image and the noisy image and R(u) is a regularization parameter. Thanks
Walter Roberson
Walter Roberson am 9 Apr. 2013
I recommend you start a new question for that.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Image Analyst
Image Analyst am 25 Mär. 2013
The Image Processing Toolbox has imgradient() and imgradientxy() functions.
  5 Kommentare
Image Analyst
Image Analyst am 8 Apr. 2013
Verschoben: DGM am 29 Dez. 2023
That does not make sense to me. In the lateral x,y direction you have units of "per pixel" but in the Z direction since the planes are different wavelengths, not distance in pixels, the gradient is not a spatial gradient. It would have units of "per wavelength". And you certainly wouldn't want a 3D gradient with spatial coordinates mixed with wavelength coordinates. It makes no sense, at least not to me.
Rawan hamdi
Rawan hamdi am 8 Apr. 2013
Verschoben: DGM am 29 Dez. 2023
Okay the thing is im that im looping on both x and y and getting the gradient in the spectral domain (z direction) the image i have is [280,307,191] so i'm trying to get the gradient of each pixel in the spectral domain and having the result as a matrix same size of the image,What should i do? Any help would be much appreciated

Melden Sie sich an, um zu kommentieren.


Anand
Anand am 8 Apr. 2013
Try this:
[~,~,Gy,Gx] = edge(imread('cameraman.tif'),'sobel');

Community Treasure Hunt

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

Start Hunting!

Translated by