matlab - Auto selecting square blob area from image : Computer Vision -


image processed trying develop auto calibration plugin, need average pixel value value of centre blob in image. of converting image binary, , able identify different blobs in image.

but, want central blob getting identified how. maybe can take of surrounding 6 small blobs.

original image: https://drive.google.com/open?id=0b9kvfpiocm1ewnhjegtbz3a4etg

matlab code:

i = imread('blob.tif'); ibw = ~im2bw(i, 0.75); ifill = imfill(ibw,'holes'); iarea = bwareaopen(ifill, 500);  stat = regionprops(ifinal,'boundingbox'); imshow(i); hold on; cnt = 1 : numel(stat)     bb = stat(cnt).boundingbox;     rectangle('position',bb,'edgecolor','r','linewidth',2); end 

your results close. after perform conversion binary, thresholding , performing area opening, image:

enter image description here

there pixels along borders of pixels still around. can use imclearborder function remove pixels touching border. absolutely sure, use 8-connectedness searches pixels in 8 directions. default use 4-connectedness north, south, east , west only:

iclear = imclearborder(iarea, 8); 

we image:

enter image description here

we're done. want entire blob detected, not different parts of blob. recommend fill of gaps using morphological closing operator. use structure element quite large ensure fill in gaps. square structure element of size 50 x 50 should work. use imclose in conjunction strel specify structure element:

se = strel('square', 50); out = imclose(iclear, se); 

we get:

enter image description here

we can use above image mask mask out of image except blob of interest multiplying mask , image together. can use mask index image directly , setting pixels not belonging mask equal 0. let's opt second option. first make copy of image, indexing:

filt = i; filt(~out) = 0; imshow(filt); 

we get:

enter image description here

it's not perfect, it's start. may have tweak parameters bit better.

good luck!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -