Prev: ordinary least squares, complex number matrix and real parameter
Next: Can you use MFC functions/libraries with s-functions and MEX compiler?
From: Nehal on 4 Jul 2010 12:14 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <4647ad4b-9804-422a-b3da-f70812f0d775(a)d16g2000yqb.googlegroups.com>... > Because you're starting with a totally different type of image it of > course required some slight modifications: wow... it works in this image.... i'll try it with the other images i have for my project... and i'll post here if those works properly or i face any problem... this was a big help... many many many thanks... :D
From: Christopher on 4 Jul 2010 19:52 "Nehal " <arnab620(a)yahoo.com> wrote in message <i0qc0d$6ms$1(a)fred.mathworks.com>... > ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <4647ad4b-9804-422a-b3da-f70812f0d775(a)d16g2000yqb.googlegroups.com>... > > Because you're starting with a totally different type of image it of > > course required some slight modifications: > > wow... it works in this image.... i'll try it with the other images i have for my project... and i'll post here if those works properly or i face any problem... > > this was a big help... many many many thanks... :D A logical solution... but just remember that not all images will be ideal, and depending on how you arrived upon your logical mask you may return regions of white (i.e. identified foreground) that aren't part of the intended object of interest (i.e. your hand). This can commonly occur due to noise and external objects. It seems that the solution proposed will crop according to the minimum/maximum rows and columns containing ANY white pixel and will therefore be inclusive of any noise included. Again.. this is perfectly fine if you ensure that your images are clearly defined with no background objects. My original solution attempted to determine which white object was the object of interest by assuming it was the largest. The problem you had when attempting to execute was correctly identified that the 'BoundingBox' parameter returns fractional bounds and any indexing must be integer. So then, you simply round it - I would suggest rounding the left and top parameters up (pushing rightward and down) and rounding the right and bottom parameters down (pushing leftward and up). The resulting loss is that of less that a pixel around the border - not really a large quantity assuming your hand would be on the order of 100 pixels wide itself. croppedIm = originalImage(ceil(boxParams(1)):floor(boxParams(1)+boxParams(3)),ceil(boxParams(2)):floor(boxParams(2)+boxParams(4))); Chris
From: Nehal on 6 Jul 2010 09:37 "Christopher " <christopher.badman(a)au.saabgroup.com> wrote in message <i0r6rg$3fp$1(a)fred.mathworks.com>... > "Nehal " <arnab620(a)yahoo.com> wrote in message <i0qc0d$6ms$1(a)fred.mathworks.com>... > > ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <4647ad4b-9804-422a-b3da-f70812f0d775(a)d16g2000yqb.googlegroups.com>... > > > Because you're starting with a totally different type of image it of > > > course required some slight modifications: > > > > wow... it works in this image.... i'll try it with the other images i have for my project... and i'll post here if those works properly or i face any problem... > > > > this was a big help... many many many thanks... :D > > A logical solution... but just remember that not all images will be ideal, and depending on how you arrived upon your logical mask you may return regions of white (i.e. identified foreground) that aren't part of the intended object of interest (i.e. your hand). This can commonly occur due to noise and external objects. It seems that the solution proposed will crop according to the minimum/maximum rows and columns containing ANY white pixel and will therefore be inclusive of any noise included. > > Again.. this is perfectly fine if you ensure that your images are clearly defined with no background objects. My original solution attempted to determine which white object was the object of interest by assuming it was the largest. The problem you had when attempting to execute was correctly identified that the 'BoundingBox' parameter returns fractional bounds and any indexing must be integer. So then, you simply round it - I would suggest rounding the left and top parameters up (pushing rightward and down) and rounding the right and bottom parameters down (pushing leftward and up). The resulting loss is that of less that a pixel around the border - not really a large quantity assuming your hand would be on the order of 100 pixels wide itself. > > croppedIm = originalImage(ceil(boxParams(1)):floor(boxParams(1)+boxParams(3)),ceil(boxParams(2)):floor(boxParams(2)+boxParams(4))); > > Chris sorry... i am not that advanced to understand this method. But yes, all the time, the images will not be ideal. For the time being, i am assuming the images are ideal and then working on it. I'll remember it and try to do something more with it. and it would be a help if u could post some more details. Thanks.
From: Nehal on 6 Jul 2010 10:02 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <4647ad4b-9804-422a-b3da-f70812f0d775(a)d16g2000yqb.googlegroups.com>... > Because you're starting with a totally different type of image it of > course required some slight modifications: > I have 15 signs (sign language signs) captured in video (avi format) with 200 frames each. I extracted each frames from each of the videos using a function. Then I have cropped it with the code you have provided. But as I have 15x200=3,000 images, i want to do it automatically. Like I want matlab to: 1. Read a video with my command. 2. It will read the 1st frame from that video. 3. Then it will save the 1st frame as a TIF image in a folder called “Frames” 4. It will read the saved image. 5. Crop the hand from the image (i do not need to see the intermediate stages) 6. Convert it to a 20x30 image (column 20 : row 30) 7. Save it to an another folder named “Cropped” 8. Then it will read the 2nd frame from the video again. 9. Then go through all the process of saving the frame, cropping the hand and saving it to the folder “Cropped”. 10. This process will go through all the frames that the video contains. That mean all the 200 frames. or It will extract all the frames and save it as image. Then read the images one by one, crop the hand and save it to another folder. I have the code for extracting the frames. I am posting it here: % the function to extract the frames as TIF from a video file function avi2image(aviname) mov = aviread(aviname); info=aviinfo(aviname); [m,n]=size(mov); [c,d]=size(aviname); for j = 1:info.NumFrames if j<10 imwrite(mov(1,j).cdata, strcat(aviname(1,1:d-4),'01_00',int2str(j),'.tif')); elseif j<100 imwrite(mov(1,j).cdata, strcat(aviname(1,1:d-4),'01_0',int2str(j),'.tif')); else imwrite(mov(1,j).cdata, strcat(aviname(1,1:d-4),'01_',int2str(j),'.tif')); end end % end of the function now if I want to do the frame extraction and cropping all together, what should I do? I was trying to create a function using a loop that will extract the frames and then crop the hand one by one from each image. But I am confused how to make matlab read the images one by one automatically where all the images have different names (increasing order). I am sharing 1 video file here: http://www.4shared.com/file/QgSCEI4I/sample.html Could you plz help me..?
From: Nehal on 9 Jul 2010 10:14
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <4647ad4b-9804-422a-b3da-f70812f0d775(a)d16g2000yqb.googlegroups.com>... > Because you're starting with a totally different type of image it of > course required some slight modifications: > I do not need all the steps I've posted in my last post here. I was trying to crop multiple image with the code you have provided... I wrote a function to do that... but it's not working... giving some errors...cannot find a variable... could u plz look at it...? plz... ? I have posted my problem here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/286532 Thanks. |