How to select a roi in greyscale image and put values to zero?

Technical Source
1 min readFeb 7, 2024

--

Hello, i have a 12bit greyscale image (tiff) which I want to be able to draw a rectangular roi and fill these values to zero (i.e. black)

This is my code, I cannot see where I am going wrong

Raw=getimage(handles.axes1);                % get image from axes component (im using GUIDE)    
h = imrect(handles.axes1); % User definable rectangle
position=wait(h)
p = h.getPosition();
position=[p(1) p(2) p(3) p(4)]; % [xmin ymin width height]
delete(h);
Raw(p(2):(p(2)+p(4)),p(1):(p(1)+p(3)))==0;  % put user specified roi to 0 (black)
axes(handles.axes1); cla reset; % Clear current axes
imshow(Raw) % Draw modified image

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help , Finance Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

Use = to assign, not == which is a comparison.

Raw(p(2):(p(2)+p(4)), p(1):(p(1)+p(3))) = 0;
mask = h.createmask();
Raw(mask) = 0;

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet