Clipping a image into small images
Show older comments
I am working on a project which is based on missing pixel restoration in a image using Back Projection for Lost Pixels(BPLP) .It is based on Principal Component Analysis(PCA).For that I need to clip the input image of size M x N into small images of size w x h .So I used the following code to clip the image (say,360x480):
for c=0:1:11
col=c*40+1;
for r=0:1:11
row=r*30+1;
clip_img=f(row:row+30-1,col:col+40-1);
end
end
The problems that I encountered in the above code are
- The clipped images got over written on the variable that I used.
- Individually I could not get the clipped images.
- I could not write the individual images to location using 'imwrite' function.
- As said the input image contains missing pixels,I found no way to separate known and unknown images.
Please help in coding the above mentioned problem.
Awaiting for your reply
[Edit: Added markup for code and numbered list. AU]
Accepted Answer
More Answers (1)
Image Analyst
on 5 Apr 2012
0 votes
Ah yes, probably our second most commonly asked question: how do I divide an image into blocks (subimages)? Probably the most common answer is to use mat2cell(). I think I favor making it a 3D image instead of cells but you can do it either way.
Can you explain what you mean by "missing Pixels"? Do you mean pixels that are black (have value 0)?
You have no indexes for clip_img - that's why it gets overwritten on each loop iteration.
Are these color or grayscale images?
Why were you not able to use imwrite() to write out clip_img? Let us see your line of code for imwrite().
1 Comment
KRISHNA MOORTHY
on 7 Apr 2012
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!