How to copy the pixels to a new buffer the size of the bounding box - copy

I want to copy and move the pixel values of an object in an image. The final image is like the original image but it will stay in another position (e.g., center position). I used the bounding box to the region object but was still not successful. It likes this picture
Please share help me or any of your ideas.

Related

Cropping the minimum sized rectangle of a shape from an image

I am making a card recognition project on MATLAB and I am stuck at this point. There are images of cards and on an image I want to define the smallest rectangle that takes the card inside. Example like below
Original image
Converted image
I am currently able to convert the image to black and white (leaves me only the cards white spaces), I want to define the rectangles by the whole white spaces. E.g., if I have 3 non-lapping cards in my image, I want to have 3 images like above (doesn't matter if another cards edge appears on the image, the important part is that rectangle must pass through the edges of the selected card).
I have tried edge definition methods but wasn't successful. Thanks for your help already.
I recommend you use regionprops function from the image processing tool box, i.e.,
bb = regionprops(yourImage, 'boundingbox');
which will return the bounding box. There is a nice MATWORKS video here and you can jump to about minute 26 for what you need.

Resizing command changes image shape

I have to resize image i.e if its dimension is 3456x5184 to 700X700 as my code needs image with less number of pixels otherwise it takes too much time to give results.So, when I use imresize command it changes the dimensions of image but at the same time it changes the shape of image i.e the circle in image which I also need to detect looks like oval instead of being cirle. I need your suggestions to resolve this problem. I am really grateful to you people.
Resizing images is done by either subsampling (to get smaller images) or some kind of interpolation (to get larger images)
Input is either a factor or a final dimension for width and height.
The only way to fit a rectangle into a square by simply resizing it is to use different scales for width and height. Which of course will yield in a distorted image.
To achieve what you want you can either crop a 700x700 region from your image or resize image using the same factor for with and height. Then you can fit the larger dimension into 700 and fill the rest around the other dimension with black or whatever you prefer.

matlab preview of live video and a circle reference at the centre of frame

I have used matlab's preview window in the following syntax:
figure('Name', 'My Custom Preview Window');uicontrol('String', 'Close', 'Callback', 'close(gcf)');
I am able to successfully get the video stream. Now I want to have a small circle as a region of interest to return the average pixel value within this circle. I want this to be stored and named after a click of a button and recalled later for the further processing.
Could anyone guide me where I can start with?
Please note I dont want user to define ROI instead its always fixed as a small circle at the centre of field view. Whatever the colours comes within the circle I want mean values to be calculated and stored as a reference.
Ps: I am not sure I am correct in calling ROI its simple circle in the field view
You might want to try using a Matlab gui instead of a simple figure. Then you could try something like this.

MATLAB: How do I resize (connected) components in a 3D binary image sequence without changing the dimensions of the sequence?

I'd like to resize the components contained in a 3D binary image sequence without changing any of the dimensions of the sequence itself.
I'm not sure if I need to do it on a component-by-component basis, if yes, then how do I create a transform such that the resized components are re-positioned 'correctly' in the image sequence? By 'correctly', I mean with the same centre of mass as the original unprocessed components.
(If that last paragraph doesn't make sense then please ignore)
A 2D example: suppose I wanted to enlarge by 10% the white blobs in the following [295x445] image
How would you do this without making the image itself larger?
you could use the imdilate function to dilate the regions of interest. The examples in the webpage show how to use this function.

how to change the position of the output result in GUI

Does any one here have an idea about how to change the position of output in the GUI matlab to be to the right side of the box and not in the center ?
i think I have to change some properties of the result text box
Check this post out: Positioning of figures
The figure Position property controls the size and location of the figure window on the screen. Monitor screen size is a property of the root Handle Graphics object. At startup, the MATLAB software determines the size of your computer screen and defines a default value for Position. This default creates figures about one-quarter of the screen's minimum extent and places them centered left to right, in the top half of the screen.
The Position Vector
MATLAB defines the figure Position property as a vector. So you may use a figure and text into it, e.g.
figure(gcf)
text(offsetX1, offsetX1, ['result 1: ' num2str(result1)])
text(offsetX2, offsetX2, ['result 2: ' num2str(result2)])
Displaying analytical results in a MATLAB GUI
This post talks about adding a static textbox with your results and positioning it.
Move GUI figure to specified location on screen:
Syntax:
movegui(h,'position')
movegui(position)
movegui(h)
movegui
The answer is pretty much trying to cover up the vauge nature of the question