MATLAB: Filtering out part of an image -


i have image of deer behind fence , i'm trying remove fence can straight @ deer without fence in way. far i've, decent quality, segmented off (determined coordinates of) fence , trying replace colors of these coordinates nearby colors simulate removing fence.

is there image processing function in matlab can me accomplish goal? have tried below code in try find nearest coordinate isn't part of fence, "~ismember([i_temp,j],[ii,jj])" doesn't work because i'm trying compare coordinates, instead seems comparing i_temp , j separate variables, i.e. i_temp not in ii or jj , j in ii or jj.

%% 5. locate pixel locations of segmented image % fence has been segmented. locate pixel locations of % segmented image  [ii,jj] = find(img_threshold2==1);  n = length(ii); % count of number of coordinates  rout = rin; gout = gin; bout = bin;  %% 6. recolor areas of fence nearest color available k=1:n     = ii(k);     j = jj(k);      keeplooping = true;     i_add = 0;     j_add = 0;     i_coord = 0;     j_coord = 0;      % find nearest coordinate not part of fence     while keeplooping         i_add = i_add + 1;         j_add = j_add + 1;          % check right         i_temp = + i_add;         if ~ismember([i_temp,j],[ii,jj])             i_coord = i_temp;             j_coord = j;             break         end          % check left         i_temp = - i_add;          if ~ismember([i_temp,j],[ii,jj])             i_coord = i_temp;             j_coord = j;             break          end           % check , down, left/right doesn't work          % since ismember doesn't work expected     end      % replace color of fence coordinate nearest non-fence     % coordinate determined above     rout(i,j) = rin(i_coord,j_coord);     gout(i,j) = rin(i_coord,j_coord);     bout(i,j) = rin(i_coord,j_coord); end 

edit 9/20/14: tried bwdist below code, iin input image , image_threshold2 segmented fence. rather getting nearest color, fence turned turquoise, makes no sense since there no turquoise in image. here screenshot demonstrating happened. cropped image can test on small area of image, actual image larger , has actual deer , whatnot. screenshot: http://gyazo.com/32ab37b8d2d9e137103d330a39d4ecfa

[d,idx] = bwdist(~img_threshold2);  % replace color of fence coordinate nearest non-fence % coordinate determined above iout = iin; iout(img_threshold2)=iout(idx(img_threshold2)); 

make binary image 1 fence , 0 remain. use [d,idx] = bwdist(bw) function of matlab. in idx have closest non-fence index. have assign voxel in fence closest non-fence value.

[d,idx] = bwdist(~mask_fence)  i(mask_fence)=i(idx(mask_fence)) 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -