From: Marcus on
b is
b 131x181 23711 uint8 array
From: ImageAnalyst on
Marcus
It works just fine. Here's proof:
(Be sure to join any lines broken into two by the newsreader).

% Demo to save and recall a cropped image.
% by ImageAnalyst
clc;
close all;
clear all;
workspace; % Display workspace panel.
% Read in standard MATLAB demo image.
grayImage = imread('cameraman.tif');
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image');
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

uiwait(msgbox('Crop the image by drawing a box, then right-clicking
and choosing crop image'));
croppedImage = imcrop(grayImage);
% Restore title that got blown away.
title('Original Grayscale Image');
subplot(2, 2, 2);
imshow(croppedImage, []);
title('Original Grayscale Image');

% Write croppe image out to disk.
imwrite(croppedImage, 'cropped_Image.bmp');

% Read it back in again to test it.
recalledImage = imread('cropped_Image.bmp');
subplot(2, 2, 3);
imshow(recalledImage, []);
title('Cropped Image recaled from disk');

uiwait(msgbox('See - it worked fine!'));
From: Marcus on
thanks sir for the proving method yea it can crop the image perfectly!
One more question how to i set the picture size if i wan all 100 x 100?
I write like that
croppedImage = imresize (croppedImage, [100 100]);
But it doesn't work why?
From: ImageAnalyst on
On Feb 5, 9:14 am, "Marcus " <sbeng_...(a)yahoo.com> wrote:
> thanks sir for the proving method yea it can crop the image perfectly!
> One more question how to i set the picture size if i wan all 100 x 100?
> I write like that
> croppedImage = imresize (croppedImage, [100 100]);
> But it doesn't work why?

------------------------------------------------------------------------------------------------
From the help documentation:
"I2 = imcrop(I, rect) crops the image I. rect is a four-element
position vector[xmin ymin width height] that specifies the size and
position of the crop rectangle."
OK, 100 is the left (xmin), and 100 is the top (ymin).
But what's your width and height? Now you see why it doesn't work.
You need to specify a 4 element vector, not a 2 element vector.
From: Marcus on
Sir if used back the demo that u show me! The cropped image is 154 x 188;
Or the weight and the height must use back original one 256 x 256?
Then if i wan to resize to 100 by 100!
R = imresize(croppedImage, [100 100 188 154]);

it appear this error when i use it on my code!
??? Error using ==> imresize>parse_inputs
M must be either a scalar multiplier or a 1-by-2 size vector.

Error in ==> imresize at 68
[A,m,method,h] = parse_inputs(varargin{:});

Error in ==> newnewiris at 84
croppedImage = imresize (croppedImage,[100 100 121 121]);
121 x 121 is after crop image! and my original image is 320x280