Derivative of an image with respect to an other image
4 次查看(过去 30 天)
显示 更早的评论
Hello, I have to take derivative of an image with respect to an other image satisfying equation dy/dx where y and x are two gray scale images of same dimension. This means, I have to take derivative of the image y with respect to the image x. A sample code is given below to proceed.
hdr_image = hdrread('office.hdr');
rgb = tonemap(hdr_image);
hdr_image=double(hdr_image);
rgb=double(rgb);
x1=0.2126 * hdr_image(:,:,1) + 0.7152 * hdr_image(:,:,2) + 0.0722 * hdr_image(:,:,3);
x=log10(x1);
y1=0.2126 * rgb(:,:,1) + 0.7152 * rgb(:,:,2) + 0.0722 * rgb(:,:,3);
y=log10(y1);
%%%%%% Now I have to take d/dx(y)
0 个评论
回答(1 个)
Kartik
2023-3-20
编辑:Kartik
2023-3-20
Hi,
To take the derivative of an image y with respect to another image x, you can use the MATLAB function 'gradient' which calculates the numerical gradient of an N-dimensional array. In your case, since x and y are two 2D grayscale images of the same dimensions, you can use the following code to calculate the derivative of y with respect to x:
[dydx_x, dydx_y] = gradient(y, x);
This will give you two matrices dydx_x and dydx_y which represent the derivative of y with respect to x in the x and y directions respectively. You can then visualize the result using the 'quiver' function to plot the gradient vectors as arrows on top of the image.
Refer to the following MathWorks documentations for more information regarding the functions used:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!