How to join two codes of images?
Show older comments
I wrote this code in a function m file:
function preprocesado(NombreImagOriginal)
ImagenOriginal=imread(NombreImagOriginal);
%Convert to a gray scale
imOrGris=rgb2gray(ImagenOriginal);
%Otsu method
Ib=graythresh(imOrGris);
BN = im2bw(imOrGris,Ib);
%Mask 40 x 40
Ibmask=medfilt2(BN,[40 40]);
% ROI
iROI=roicolor(Ibmask,1);
%Cortar
imcrop(iROI);
Then I copied the coordinates of the ROI in the next small code:
I=imread('NombreImagOriginal'); %(ie. '5332.jpg')
>> I2=imcrop(I,[1359.5 549.5 1170 1224]);
>> imshow(I2)
Then I got an image like this:

In the picture there is not the white background but if you copy-paste the code you will see it. Now my problem is that I don't know if there is a way to join the two codes, and not copy-paste the coordinates. Also I want to disappear the white background because I just want the image in order to apply another code. Because if I keep the white background I get the next image when I apply a code for the red channel.

Actually I disappear the white background manually but I want to know if there is a manner to do it automatically.
Thank you for your time.
Accepted Answer
More Answers (1)
Image Analyst
on 17 Jun 2014
0 votes
I'd like to help but I don't know how. What white background you're talking about? All I see is an orange image (presumably the original image), and a pseudocolored image. I don't see any cropped image or image with a white background. Please attach your script and original image.
Do you want to use fixed cropping coordinates? Or do you want to have the user select where to crop?
Categories
Find more on Image Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!