필터 지우기
필터 지우기

Matlab - perform a function of all matrix cells

조회 수: 2 (최근 30일)
Despairy
Despairy 2012년 11월 13일
Hello,
I have loaded a grayscale image into img so now I have a one matrix in it.
Now I used plot to show a graph of a function and I would like to use this function over all of the matrix values and actually change the gray values of the image.
I do know the "A(A>0) = value" function but I'm not sure how to use it with the plot I've made.
XData=get(get(gca,'children'),'XData');
YData=get(get(gca,'children'),'YData');
% Get y value for x=3.33 - NOT a data point.
y_3p33 = interp1(XData,YData,3.33,'spline')
(c) paulo silva http://www.mathworks.com/matlabcentral/answers/1353 so this is actually the way of getting the new Y point for each value but how can I use it over all the matrix cells in a fast way? (actually in any way)
thank you!
  댓글 수: 1
Jan
Jan 2012년 11월 13일
Please use meaningful tags. Obviously all questions in thius forum concern "matlab code".
Do you mean "matrix elements"? "Cells" are a special type of arrays, which can contain elements of different types.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
Jan 2012년 11월 13일
Please use meaningful tags. Obviously all questions in thius forum concern "matlab code".
Do you mean "matrix elements"? "Cells" are a special type of arrays, which can contain elements of different types.
I do not see the connection between the XData and YData of your graph and the loaded image. What exactly is a "one matrix"? Are you looking for:
A2 = reshape(interp1(XData,YData, A(:), 'spline'), size(A));

Despairy
Despairy 2012년 11월 13일
img=imread('filename');
so img now holds a matrix (the file is a grayscale image) of the gray values of the image.
now I have a plotted function on axes1
lets say f(100)=20
and f(250)=50
so now I want the gray values to change according to the function plotted from what I read about the reshape function it is not exactly what I'm lookin for.
actually what I want is the following to happen
A(A=100)=20
A(A=250)=50
but for all of the values between 0 and 255 using the function plotted.
thanks for your help

카테고리

Help CenterFile Exchange에서 Geometric Transformation and Image Registration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by