필터 지우기
필터 지우기

Derivative of an image with respect to an other image

조회 수: 2 (최근 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