Simple croping application

176 views
Skip to first unread message

DeGriz

unread,
Apr 3, 2012, 6:58:05 AM4/3/12
to marvin-...@googlegroups.com
I want to create application based on Marvin Framework. I want to be able select area on a loaded image using mouse, crop image down to selected area and save cropped image to a file. Is there a simple way to do that?

Gabriel Archanjo

unread,
Apr 3, 2012, 8:29:16 PM4/3/12
to Marvin Developers
Hi,


Cropping an image using Marvin:

// 1. Load original image
MarvinImage image = MarvinImageIO.loadImage("./image.jpg");

// 2. Crop image using the method image.crop(x,y,width,height)
MarvinImage imageCrop = image.crop(50,50,100,100);

// 3. save the new image
MarvinImageIO.saveImage(imageCrop, "./imageCroped.jpg");


You just need to collect the x,y,width,height using the mouse
interface.

DeGriz

unread,
Apr 4, 2012, 3:06:18 AM4/4/12
to marvin-...@googlegroups.com
I almost done it at this moment. I'll post the code here (using Pastebin) after I finish, if don't mind.

среда, 4 апреля 2012 г. 4:29:16 UTC+4 пользователь Gabriel Archanjo написал:

DeGriz

unread,
Apr 4, 2012, 9:24:40 AM4/4/12
to marvin-...@googlegroups.com
Well, it's as easy as I expected. I created subclass from MarvinImagePanel where I'm able to retreve mouse selection. But I want to be able to rotate picture using "org.marvinproject.image.transform.rotate" plugin. I wrote this code:
http://pastebin.com/akMKeEFF
, but it doesn't work (with and without "this.rotatorPlugin.show();" line).
I understand that it's because plugin needs an angle to rotate picture, but I don't know how to transfer it. Can you please help on that problem?


среда, 4 апреля 2012 г. 4:29:16 UTC+4 пользователь Gabriel Archanjo написал:
Hi,

Gabriel Archanjo

unread,
Apr 4, 2012, 9:38:20 AM4/4/12
to Marvin Developers
private MarvinImage rotateImageLeft(MarvinImage mImage) {
                MarvinImage newImage = mImage.clone();
                this.rotatorPlugin =
MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.transform.rotate.jar");

                // set the angle attribute
this.rotatorPlugin.setAttribute("RotateAngle", 45);

                this.rotatorPlugin.process(mImage, newImage, null,
MarvinImageMask.NULL_MASK, false);

// update the buffered image inside MarvinImage
(Necessary for MarvinImagePanel)
newImage.update();

                return newImage;

Ssk

unread,
May 1, 2022, 7:02:01 PM5/1/22
to Marvin Project
While dealing with cropping images after detecting corners, can it be done for the image based on the location of the corners? If yes, how can this be done?

With respect to the crop region, instead of setting up the crop size, can the crop region be defined in a responsive manner, may be, rectangular or circular region  that would work across devices?

Any examples available for these?

Thanks.

Ssk

unread,
May 1, 2022, 9:35:24 PM5/1/22
to Marvin Project
Ao lidar com imagens de corte após detectar cantos, pode ser feito para a imagem com base na localização dos cantos? Se sim, como isso pode ser feito?

Com relação à região de cultivo, em vez de configurar o tamanho da colheita, pode a região de colheita ser definida de forma responsiva, pode ser, região retangular ou circular que trabalharia em dispositivos?

Alguns exemplos disponíveis para estes?

Obrigado.

Not a native speaker of Portuguese - Please bear with me, and let me know whether the above translation is Ok.

Joseph Smith

unread,
May 27, 2022, 11:02:15 AM5/27/22
to Marvin Project
@Gabriel, 

I am new potential user. Seems the documentation and code samples are very outdated. 

Fcuk, just realized this thread is from 2012. How do you load a plugin now? 

imagePlugin = MarvinPluginLoader.loadImagePlugin("org.marvinproject.image.color.grayScale.jar");

Does not work. 

Reply all
Reply to author
Forward
0 new messages