How to replace specific areas in matlab figure by zero?
조회 수: 2 (최근 30일)
이전 댓글 표시
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'?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163795/image.jpeg)
댓글 수: 0
채택된 답변
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
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!