RGB =imread('image.jpg');
hsv= rgb2hsv(RGB);
imshow(hsv);
r1=0.1;
r2=0.85;
i= 0:20:240;
s= 0.0:0.2:1.0;
wgray = 1 - bsxfun(@power, s(:), (r1*(255./(i(:).')).^r2) );
P=diff(wgray,s);
i want to calculate partial derivative of wgray w.r.t s and i have applied but getting error in line 9

 Réponse acceptée

Star Strider
Star Strider le 4 Fév 2016

0 votes

I would use the gradient function. It returns two matrices, the partial derivatives in each direction of the input matrix, both the same size as the input matrix. You can use one or both of the returned derivative matrices.

6 commentaires

kalyani ohri
kalyani ohri le 5 Fév 2016
Ok sir...as Wgray is a matrix they are again giving error and i have applied gradient(wgray,s) i want to calculate partial derivative of wgray w.r.t s. Actually m new to matlab so getting some difficulty
Thanks..
The gradient function wants a single non-zero scalar value for the second argument that represents the (assumed) constant spacing in a particular direction.
Since the step in your ‘s’ vector is 0.2, you would call the gradient function as:
[FX,FY] = gradient(wgray, 0.2);
That should work.
kalyani ohri
kalyani ohri le 6 Fév 2016
Thank u so much sir.. As value of s varies from 0.2 to 1.0 i need to use gradient function 6 times gradient(wgray,0.2); gradient(wgray,0.4); gradient(wgray,0.6); gradient (wgray,0.8); gradient(wgray,1.0);
thanks once again.
Star Strider
Star Strider le 6 Fév 2016
If your constant step size varies, you would either need to re-calculate the numerical gradient, or interpolate a gradient calculated from a lower (finer) step size to a different step size.
If it is a vector of step sizes varying over the dimensions of the vector or matrix you are calculating the gradient of, if I remember correctly, there are File Exchange contributions that will allow you to use a varying grid width to calculate the gradient. Search the File Exchange to see which of those works best for you.
As always, my pleasure.
kalyani ohri
kalyani ohri le 6 Fév 2016
Thanks Sir..
Star Strider
Star Strider le 6 Fév 2016
My pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Produits

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by