« first day (1 day earlier)      last day (3227 days later) » 

7:58 AM
@rayryeng: thanks for setting up the room!
 
 
4 hours later…
11:42 AM
Hello, hello
 
hello MATLABers :)
@rayryeng: thanks for the invite
 
How are you guys
 
I'm good. It's nice to see you guys create a MATLAB room.
 
hehe thanks cool
 
I remember we tried it a few years ago, but it didn't last too long ;)
 
11:50 AM
well it was @rayryeng
hehe
well as long as u keep active
and try to "promote" on questions and posts
I'm new to matlab
Im learning image processing
so I tooka book and Im trying to timplement everything with matlab
actually, could u check out this
0
Q: What's the issue in this MATLAB Prewitt operator implementation?

diegoaguilarI'm trying to code an implementaiton of the Prewitt operator for edge detection. So far I've tried: openImage = im2double(rgb2gray(imread(imageSource))); [rows,cols] = size(openImage); N(1:rows,1:cols)=0; for i=1:rows-2; for j=1:rows-2; N(i,j)=-1*openImage(i,j)-1*openImage(i,j+1)-1...

:P
 
thats a good way to learn..
Let me take a look :)
 
@diegoaguilar Could you add the original image as well?
 
Sure, wait
 
@diegoaguilar: Before looking at the code, have you considered using convolution operation?
help conv2
 
I just did ...
but I got "distinct" results than by using edge function
I'll also share that or post another question
 
11:56 AM
could it be difference in the way it handles borders?
if that's the case, you could try "padding" the image before applying the operator, then crop the result back to the original size..
 
By using conv2 I got this
 
@diegoaguilar The result that you show, is that the variable N or O?
 
it was Z = N + O
 
Oh, I read it as N + zero...
 
12:01 PM
according to WP, shouldn't the final gradient be Z = sqrt(N.^2+O.^2)?
also pay attention to the range of the result (if it's not in [0,1], you'll need to map it as such when displaying the image)
 
It shows half black half white by Z = sqrt(N.^2+O.^2)
 
12:33 PM
@Amro I get a completly white image by trying what u just suggested in tehe post
 
@diegoaguilar: did you display the image using: imshow(out,[])?
(note the second argument)
either that, or you'll have to map the values to the [0,1] range like I mentioned before...
 
Ok so, this subplot(2,2,1),imshow(Z,[]) works
but imshow(im2bw(Z),[]) won't, white image again
 
@diegoaguilar: MATLAB image functions expect double images to be in the [0,1] range. So if you want to use im2bw, you're gonna have to manually map Z to that range...
It's not difficult, just do: ZZ = (Z-min(Z(:))) ./ range(Z(:))
 
cant I just do double()
?
 
@diegoaguilar: to understand what I meant, try inspecting the range of values of Z as it is. See min(Z(:)) and max(Z(:))
 
12:46 PM
@Amro I have an intermediate question, I did this for using conv2
but implementation with conv2 against edge function with Prewitt method are not the same
is that because of the thinning?
 
dunno, try disabling it: `edge(I, 'Prewitt', [], 'both', 'nothinning') ?
 
I get [a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin{:});
error
but that's not what docs say
:(
Actually I get
Warning: CONV2 on values of class UINT8 is obsolete.
Use CONV2(DOUBLE(A),DOUBLE(B)) or CONV2(SINGLE(A),SINGLE(B))
instead.
> In uint8/conv2 (line 10)
In prewitt_matlab (line 44)
Warning: CONV2 on values of class UINT8 is obsolete.
Use CONV2(DOUBLE(A),DOUBLE(B)) or CONV2(SINGLE(A),SINGLE(B))
instead.
> In uint8/conv2 (line 10)
In prewitt_matlab (line 45)
Error using edge>parse_inputs (line 485)
Invalid input string: 'notthinning'.

Error in edge (line 189)
[a,method,thresh,sigma,thinning,H,kx,ky] = parse_inputs(varargin{:});
 
you have an extra "t" in there...
"nothinning"
 
btw, you should use im2double to get a double image (to silence the CONV2 warning)
 
12:54 PM
ok..
maybe thats why images are not the same yet?
 
I thought you already have that in your questions on Stack Overflow..
 
@Jonas - No problem! Glad to see you here!
@Amro - hehe... well I figured that this room will survive a little longer as long as I'm active... but thank you for coming :)
 
@rayryeng: hey there!
 
@diegoaguilar - @Amro - is correct. Try converting your image to double before convolving with the Prewitt mask.
 
@diegoaguilar
btw, if you look at the source code of EDGE function (`edit edge`),
you'll see the following comment at the top:

% [BW,thresh,gv,gh] = EDGE(I,'prewitt',...) returns vertical and
% horizontal edge responses to Prewitt gradient operators. You can
% also use these expressions to obtain gradient responses:
% if ~(isa(I,'double') || isa(I,'single')); I = im2single(I); end
% gh = imfilter(I,fspecial('prewitt') /6,'replicate'); and
% gv = imfilter(I,fspecial('prewitt')'/6,'replicate');
 
12:59 PM
@Amro - Greetings!
 
@diegoaguilar: the reason they use imfilter vs. conv2 is because it can handle linearly separable kernels in an optimized way: mathworks.com/matlabcentral/answers/…
 
@Amro - They tried making one several years ago? It's unfortunate it didn't last long... well I hope to make it stick around for a lot longer! I'll try and make things exciting :)
@Amro - Does that also tie in with IIPP?
 
thanks @Amro
 
@rayryeng: I'm sure you will :) I found the old room here: chat.stackoverflow.com/rooms/2793/matlab
 
so its way of "impossible" get same visible results
with edge
 
1:05 PM
@rayryeng: could be, IPP certainly has optimized implementations for convolution
 
@diegoaguilar - edge also thresholds the image.
What you are computing is just the gradient.
 
but thats why I apply im2bw to my implementation
 
are you using 'nothinning' as the flag?
 
@diegoaguilar: did you look into the "border handling" I mentioned earlier?
 
@Amro - Gotcha :) and thanks for the link to the old room... I'm surprised.
it looked very active up until your last message.
 
1:13 PM
@diegoaguilar: I just noticed in your code snippet that you divide by 256. Shouldn't that be 6 (i.e sum(kernel(:))) ?
 
@Amro - aha!
 
I meant sum(abs(kernel(:)))
 
1:41 PM
@Amro I dont understand this last about sum(abs(kernel(:)))
:(
 
@diegoaguilar: in the snippet you posted, you wrote: b=[-1 -1 -1;0 0 0;1 1 1]/256. It should be divided by 6 instead, which is the sum of the absolute values of the kernel. This normalization is done to ensure the output is in the same scale as the input image
i.e the weights in the convolution are 1/6 and -1/6 (weighted sum)
where the weights total sum is 1
 
1:58 PM
To explain it differently, imagine you had a constant image like `img = 0.5*ones(10)`, and apply a kernel where all weights are one (basically an averaging kernel). Convolving the image with the normalized kernel leaves it unchanged (ignoring the border thing), whereas the unnormalized kernel would scale it outside the original range.

E.g: `conv2(0.5*ones(10), ones(3), 'valid')` vs. `conv2(0.5*ones(10), ones(3)./9, 'valid')`

Makes sense?
 
@Amro - Spot on. A lot of people forget to normalize convolution masks and this is the reason why.
 
 
1 hour later…
3:16 PM
Sorry if this is a dumb question, but I was wondering about running a fspecial 7 term moving average filter on a binary image. Would it average all pixels within 7 pixels of that pixels (a circle with radius of 7)?
 
can you just give the line of code?
 
What is a "fspecial 7 term moving average filter"?
fspecial defines 2D convolution masks... 7 terms is a bit ambiguous.
 
kxy7 = fspecial('average', 7);
current_im_bw = im2bw(current_im , thr);
current_im_filtered = imfilter(current_im_bw,kxy7);
 
That is a 7 x 7 averaging filter.
it takes 7 x 7 pixel neighbourhoods and finds the average in each
not a circle.
 
Ah, got it.
 
3:18 PM
So explicitly, if we had.. say... a 15 x 15 image
and we wanted to find the output at the centre... (8,8)
it would collect pixels within a 7 x 7 window at this centre
so from rows 5-11, columns 5-11.
add up all values in this window and divide by 49.
so the neighbourhood is technically a square.
If you wanted to have a circular blur, consider using a Gaussian filter.
 
Oh, okay. That makes sense. Thanks!
 
no problem!
 
I'm trying to understand my boss' code he uses for image processing (originally I was just building a GUI that would call it but now I need to understand it).
 
so for each output pixel location in your image, we look at the same location in the input image, collect 7 x 7 pixel neighbourhoods and find the overall average
this average is what is output at the same location in the output image
No worries. If you have any other small questions, post them here.... especially if it's image processing :) I love that stuff! lol
 
Your example helps a lot, since I looked up the 1D example and it made sense, but was confused as to how it would apply in 2D. Much thanks!
 
3:21 PM
yeah you basically have another dimension to consider.
so instead of collecting a single array of pixels, it's now a 2D grid
so think of it as a moving average where instead of a sliding 1D window
it's now a sliding 2D window that traverses left to right, and top to bottom in your image
there's another degree of freedom to consider.
No problem. My pleasure!
 
 
3 hours later…
5:58 PM
1
A: Matlab indexing variable for a specific element or the last element

rayryengIt's very simply: out = vector(end); end is a reserved keyword. Your use of eval is implying that end is used as a variable, hence the reserved keyword error. If I can suggest something, try and avoid using eval. It makes your code hard to read. Here's a good article by Loren Shure on wh...

Reading the question over and over again, the answer seems to just use the end keyword
however the OP is not satisfied with that requirement... can someone else read the question and answer and see what I'm missing?
 
 
1 hour later…
7:17 PM
@Amro "I remember we tried it a few years ago, but it didn't last too long" Do you mean chat rooms are automatically closed if there's not enough activity? (I know, I know, I should read up on chat rules in SO...)
 
7:28 PM
@LuisMendo: I dont use SO chat often either, but I think the room gets frozen and archived if there's no activity for a certain period of time. The transcript would still be available though..
 
@Amro - Yes I see the transcript.
 
we are way past the worthiness threshold :)
 
lolol
If you look at the stats, I compose of mostly (75%) of the messages here.
 
Have you guys tried the App Designer that was apparently released a while ago? mathworks.com/products/matlab/app-designer/tech-preview.html
2
I'm just hearing of it, but I only have R2015a installed on my machine, so I can't try it :(
(it requires R2014b)
It's supposed to be the successor of GUIDE.. finally!
 
@Amro - No I never have...
TBH, I've never really developed GUIs through MATLAB lol
... though I should invest in learning it soon
 
7:42 PM
well maybe you should wait til it's released. GUIDE is a horrible mess imo
 
So I've been told... that's the reason why I've been delaying it
 
 
2 hours later…
9:27 PM
@Amro Thanks for the link!
I hadn' heard of App Designer. I don't like GUIDE much either. But now all my knowledge about that (not that it's much anyway) will become useless. Oh well
 
 
2 hours later…
11:57 PM
Hello, what's difference between edge and fspecial functions for edge detection
I see they also got Sobel or Prewitt, for example mathworks.com/help/images/ref/fspecial.html
 

« first day (1 day earlier)      last day (3227 days later) »