How to replace specific areas in matlab figure by zero?
5 次查看(过去 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!