필터 지우기
필터 지우기

How to replace specific areas in matlab figure by zero?

조회 수: 5 (최근 30일)
Sachin Nag
Sachin Nag 2017년 5월 5일
댓글: Walter Roberson 2017년 5월 9일
I have a matlab figure file as shown below. I have extracted this image into a matrix named 'figmat' using the code
openfig('newmeas.fig');
figmat=get(get(gca,'Children'),'CData');
1) How to know which rows and columns in 'figmat' correspond to this bottom yellow line?
2) How to replace the bottom bright yellow line with zero values in 'figmat'?

채택된 답변

Walter Roberson
Walter Roberson 2017년 5월 6일
You can see that the axes increase in both directions away from the bottom left corner. In MATLAB, that is the case when the axes XDir and YDir properties are both set to 'normal'. When they are both set to normal, then the lower left corner of the display corresponds to CData(1,1,:), and the upper left corner corresponds to CData(end,1,:); the lower right corresponds to CData(1,end,:) . The bright yellow line therefore corresponds to rows near the beginning of the CData.
It is not clear to me that the line corresponds to CData(6,:,:) only; there might be a couple of values in the row before or after that which have the same color.
I would suggest trying
f = openfig('newmeas.fig');
obj = findobj(f, 'hasprop', 'CData');
figmat = get(obj, 'CData');
fm2 = figmat;
fm2(6,:,:) = 0;
set(obj, 'CData', fm2);
  댓글 수: 11
Sachin Nag
Sachin Nag 2017년 5월 9일
편집: Sachin Nag 2017년 5월 9일
@Walter, thanks for the suggestions. I tried with few things and obtained the image as uploaded here where I could get some of the bottom rows to be valued to zero. But now an other question remains for me. The light blue color (cyan) sloped line you see approximately between the values 300 and 400 is a useful signal and the values from 200 and below (with the same color) are noise.
1) How to make only the noise part zero preserving the values of the useful signal?
2) Is there any way to extract portion of images as a matrix or identify in the original matrix which row/column corresponds to which part in the image?
Thanks for any assistance
Walter Roberson
Walter Roberson 2017년 5월 9일
"Is there any way to extract portion of images as a matrix or identify in the original matrix which row/column corresponds to which part in the image?"
With the plotting you have done, the x coordinate is the column number of the data, and the y coordinate is the row number of the data.
"How to make only the noise part zero preserving the values of the useful signal?"
You really need to go back to the original data instead of working with the drawn data.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by