Manipulate '1' values in binary matrix
1 view (last 30 days)
Show older comments
I have a binary matrix and I need to create a convolving function that manipulates only the '1' values. In other words, I want to create second matrix where the '0' values remain in the same place but the '1' values are replaced with the output of the function that manipulated them. Any thoughts?
0 Comments
Accepted Answer
Image Analyst
on 3 Jan 2015
Just create a mask for the zeros and multiply your output by the mask
% Create mask
mask = originalMatrix == 0;
% Do the convolving with conv2d() or any custom function you want
% to get some new matrix.
newMatrix = conv2d(originalMatrix, yourKernel, 'same');
% Put zeros of original back in
newMatrix(mask) = 0;
More Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!