From: Julia Weidner on 28 Jul 2010 13:34 I am working with very large image in matlab so they can't be completely loaded into the working memory of matlab. I started messing around with blockproc but have found that it is very limited in its use since it calls an anonymous function and only returns an image to the workspace. The following code, for example, would return a variable "image" to the workspace and then you would have to write this image to a folder: image=blockproc('image1.tif', [10 10], @(block_struct) imresize(block_struct.data, .5)) The images I am working with are so large that I can't create an "image" variable to put in my workspace and I just save the processed image directly to a destination: blockproc('image1.tif', [10 10], @(block_struct) imresize(block_struct.data, .5), 'Destination', 'newimage.tif') I have successfully saved my newimage to a folder in my directory but now I want to know other things about my picture (like the average RGB values) but all blockproc does is save an image. What if I wanted to create a hsitogram of Red values for the image? How would I go about doing this?! Thanks in advance!
From: ImageAnalyst on 28 Jul 2010 15:17 Like Walter said, histogramming can get tricky if it's not uint8. (I have demos for other data types if needed.) What you might try is to save the histograms of each block, and add them into the "cumulative" histograms, which you're building up for the entire image, using the "persistent" or "global" keywords, or getappdata() and setappdata().
From: Walter Roberson on 28 Jul 2010 15:30 ImageAnalyst wrote: > Like Walter said, histogramming can get tricky if it's not uint8. (I > have demos for other data types if needed.) > > What you might try is to save the histograms of each block, and add > them into the "cumulative" histograms, which you're building up for > the entire image, using the "persistent" or "global" keywords, or > getappdata() and setappdata(). Perhaps, %MaxValue would be 1 or intmax(class(TheImageName)) RGBSelect = 1; binedges = linspace(0,MaxValue,NumBins); T = blockproc(TheImageName, [10 10], @(v)histc(reshape(v.data(:,:,RGBSelect),1,[]),binedges) ); thehistogram = sum( reshape(T .', NumBins, []), 2 ) .'; Except that I would use a block size bigger than 10 x 10 for efficiency. Oh, and be warned that if the original image could not be duplicated because doing so would overflow memory, then the above will almost certainly overfill memory... unless, that is, you use a block size that has more pixels than the number of bins you are accumulating into. You want efficiency, you don't use blockproc ;-)
|
Pages: 1 Prev: Field Oriented Control of PMSM Next: change the suffix of a file from MATLAB |