How to join two codes of images?
显示 更早的评论
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.
采纳的回答
更多回答(1 个)
Image Analyst
2014-6-17
0 个投票
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?
类别
在 帮助中心 和 File Exchange 中查找有关 Image Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!