I'm saving my mask1 in a folder to visualize the image processing but i want to add to my image (when im using imwrite) my rectangle (BoundingBox) in the same image. I create my bounding box with :
s=find([numberOfblobs.Area]>500 & [numberOfblobs.Area]<3500);
Here's my code:
% function [ image ] = BatchLAB()
clear all;close all;%Delete images in output folder
delete('C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\traiter\*.jpg');% Go get all my Jpgs in my folder
files=dir('C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\*.jpg');addpath('C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test');addpath('C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\traiter');%Batch processing loop
for k=1:numel(files) cform = makecform('srgb2lab'); img=imread(files(k).name); imgLAB=applycform(img,cform); img1=imresize(imgLAB,[800 800]); imgBW=im2bw(img1); imgBW1 = bwmorph(imgBW,'shrink'); imgBW2 = bwmorph(imgBW1,'majority'); imgBW3 = bwmorph(imgBW2,'thin'); mask = imopen(imgBW3, strel('Disk',1)); mask1 = imfill(mask,[200 200],6); [L Ne]= bwlabel(mask1); numberOfblobs=regionprops(L,'all');for n=1:size(numberOfblobs,1)rectangle('Position',numberOfblobs(n).BoundingBox,'EdgeColor','r','LineWidth',2)ends=find([numberOfblobs.Area]>500 & [numberOfblobs.Area]<3500);for n=1:size(s,2)rectangle('Position',numberOfblobs(s(n)).BoundingBox,'EdgeColor','g','LineWidth',2)endoutput_name=['C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\traiter\' files(1).name];imwrite(mask1, ['C:\Documents and Settings\sidussault\Bureau\Projet intervention\Image test 3\00020_07_230_000D_D1_(0)_20110503_d\Test\traiter\' files(k).name]);end
Best Answer