[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 33 KB, 560x420, matlab_1.gif [View same] [iqdb] [saucenao] [google]
6490274 No.6490274[DELETED]  [Reply] [Original]

Hey guys
Any one that uses Matlab? my code gives me
the following error:Undefined function 'imoverlay' for input arguments of type 'uint8'.
and I'm about to cry cause I don't know how to solve this shit.

This is my code:
%read the picture and convert
%it to .tiff file
I = imread('bath.jpeg');
imwrite(I, 'bath.tiff');
figure, imshow(I);

%turn the image in grayscale
%for two dimensional convertion
%to apply edge detection
J = rgb2gray(I);
threshold = graythresh(J);
figure, imshow(J);

%apply edge detection
ED = edge(J,'canny');
figure, imshow(ED);

OV = imoverlay(J,ED, [0 255 0]);
figure, imshow(OV);

>> No.6490285

make sure your variables are as they are supposeed tyo be, somwtiimes arrays get messed up with wrong number of elements

>> No.6490298

did you try looking in the documentation for imoverlay()?

function out = imoverlay(in, mask, color)

COLOR should be a 1-by-3 vector of values in the range [0, 1]. [0 0 0]
% is black, and [1 1 1] is white.

>> No.6490307

>>6490298
Yeah I did that.
My initial code was
OV = imoverlay(j, ED, [0 0 0]);

>> No.6490312

I just found that the conversion I make from .jpeg to .tiff is completely unnecessary. It still gives me the same error.

>> No.6490320

what format does edge() output in? rgb2gray() and graythresh() should be leaving you with uint8, but the docs aren't clear on what format edge() is giving you

maybe try converting ED to uint8 and multiplying by 255?

>> No.6490321

>>6490274
1. Is the function supported in your version of Matlab?
People have wasted a shitload of time to realise some functions were deleted in Matlab 2013.

2. Is your syntax correct?
Try finding an example of use of function on the net.

3. Ditch Matlab. Thank me later.
Matlab is regarded as top science only for superficial engineers and economists. Apart from being generally lousy and a dead end to learn ( learning Matlab will only aid you with using Matlab thus locking you into being their customer) Matlab uses pretty much exclusively freely available libraries written in C or similar. I suggest you man up and learn to program using those libraries. If you do not want to learn C or other languages you can use Mathematica instead which is a lot cheaper than Matlab and higher quality. It does not however provide you with all the junk that makes people that don't know what they're doing look somewhat average.

>> No.6490322

>>6490321
>People have wasted a shitload of time to realise some functions were deleted in Matlab 2013.
jesus christ how horrifying

why would mathworks do that instead of just having something pop up and be like "yo this function is old don't use it"

>> No.6490324

>>6490321
>Matlab is regarded as top science only for superficial engineers and economists.
it's used a lot in a couple different sub fields of biology

>> No.6490328

>>6490320
That is a very good question. To be completely honest I have no idea. I am currently trying your idea

>> No.6490331

>>6490328
you should be able to look at the variable browser and tell right away what format ED is

>> No.6490340

>>6490321
It should be. There is no indication that it is not. I downloaded the most recent Matlab that includes image processing toolbox and all that shit, plus most of the image processing functions I used before seemed to work perfectly fine

>> No.6490356

>>6490331
It doesn't mention or maybe I am just retarted and I can't see it.
Furthermore, matlab -_-

>> No.6490359

>>6490356
i meant matlab crushed* -_-

>> No.6490364

>>6490356
provide a screenshot

>> No.6490383

>>6490274
>>help imoverlay
its not that hard nigga

>> No.6490394
File: 640 KB, 2878x1604, Screen Shot 2014-04-20 at 19.23.02.png [View same] [iqdb] [saucenao] [google]
6490394

>>6490364
there you go

>> No.6490401

>>6490274
>uint8
cast to doubles and divide by 255 before passing it

>> No.6490405

>>6490401
What do I double and what do I divide exactly?

>> No.6490413

Can you take a lesson on variable naming first holy fucking shit.

Is Image so much harder to type than I?

And ED for Edge Detection? What the fuck faggot

>> No.6490415
File: 300 KB, 1004x559, untitled.png [View same] [iqdb] [saucenao] [google]
6490415

>>6490394
>ED
>logical

OV = J;
OV(ED)=125;%or what ever GRAY value you want (J is grayscale)

If you want to modify your color image
OV=I;
OV1=I(:,:,1);
OV2=I(:,:,2);
OV3=I(:,:,3);
OV1(ED)=0;
OV2(ED)=255;
OV3(ED)=0;
OV(:,:,1)=OV1;
OV(:,:,2)=OV2;
OV(:,:,3)=OV3;
figure, imshow(OV);

I'm sure you can pack it into one operation but I'm too lazy to remember how...

>> No.6490416
File: 498 KB, 1350x2000, bait.jpg [View same] [iqdb] [saucenao] [google]
6490416

>>6490413
good try

>> No.6490419
File: 69 KB, 840x473, iKleVxj9WtXI.jpg [View same] [iqdb] [saucenao] [google]
6490419

>>6490415
original for comparison

>> No.6490421

>>6490405
>what do I double exactly
Maybe you should just drop the class.

>> No.6490423

>>6490415
I don't really get how that will help me.
The variable OV is supposed to be the final overlaid image that I get from using J as that main pic and ED as the mask. I think >>6490421 is right. Maybe I should drop the class

>> No.6490427
File: 214 KB, 1004x559, untitled2.png [View same] [iqdb] [saucenao] [google]
6490427

>>6490423
Then

OV = J;
OV(ED)=255;

or

OV1=J;
OV2=J;
OV3=J;
OV1(ED)=0;
OV2(ED)=255;
OV3(ED)=0;
OV(:,:,1)=OV1;
OV(:,:,2)=OV2;
OV(:,:,3)=OV3;

is your answer

>> No.6490437

>>6490427
That is working. How can I thank you?

>> No.6490469
File: 73 KB, 300x301, d8645be9-482b-44fd-8745-89144c1d2.jpg [View same] [iqdb] [saucenao] [google]
6490469

>>6490321
> use mathematica

best advice ever.

M9 has sick graphics processing. Used to use matlab, never again.