Derivative of an image with respect to an other image

6 ビュー (過去 30 日間)
Abdulllah
Abdulllah 2022 年 11 月 30 日
編集済み: Kartik 2023 年 3 月 20 日
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)

回答 (1 件)

Kartik
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:

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by