examine picture through sliding window - matlab

I have this image (too large to include) (2351x997) and I'm trying to detect the horizontal lines, first I have to apply a window as
M=T(1:d,1:l);
T is my image, d is width (4 pixels) and l is the length (l=0,2*2351) of my area of interest. Then in this window I have to count black pixels (n), the mean value (m) and standard deviation (σ).
Afterwards if n/(lxd) >0.6 and σ<1,2 I assume I detect a line.
The applied window will slide through image in step of l/4

You can try follow this example,
SCW Example

Related

How to find height of the specific point in this OCT image?

I am a beginner in Matlab who is working on medical image processing of retinal OCT images. My aim is to align all the images to 1 height value. I want to find the maximum height of the layer in the eye.
For example, if input :
the output: returns this height:
I have tried this approach as outlined in Hand_height but it returns the height of the complete image.
Iterate over X and find the first peak (blue point) using findpeaks in the vertical direction (Y) to generate the first layer (blue line),
and then determine the peak with the smallest index in the Y-direction.
Please see the image!
In order to find maximum high you should find the top border of a retina.Here you have an example of how to find it.

find accumulated frame difference energy image

I have gait recognition system using matlab. I want to find accumulated frame difference energy image (AFDEI) from frame difference image.By weighted average method, the AFDEI is obtained, which can reflect the time characteristic. Next formula shows how to calculate the accumulated frame difference image:
𝐴(𝑥,𝑦) = 1/N Σ 𝐹 (𝑥,𝑦, 𝑡) where Σ from t=1 to N
This is my frame difference images (5 image )
frame difference images
I want to find accumulated frame difference energy image (AFDEI) like this :
result image
I am try to sum 5 image and taking average put it give my a very different image .
So how to find AFDEI ?
I gave a shot at this:
There is some sort of post processing filtering after averaging the images.
This is the result from averaging:
And this is after applying a mode filter with a 3x3 window to the previous image:
So I'd say that your target image is using some sort of smarter colouring algorithm. Not sure at this, but it's like it overlaps the borders of the original frames, then fills the resulting zones with the mode/modal value of the AFDEI
EDIT: Mode filter used above
function target = modeFilter(origin)
%origin is a monochrome IMG matrix
%being lazy with the margin, you may resize to filter the borders,
%without OOB exceptions.
target=origin;
[h,w]=size(origin);
for x=[2:w-1]
for y=[2:h-1]
target(y,x)=mode(origin(y-1:y+1,x-1:x+1)(:));
end
end
end

Resizing command changes image shape

I have to resize image i.e if its dimension is 3456x5184 to 700X700 as my code needs image with less number of pixels otherwise it takes too much time to give results.So, when I use imresize command it changes the dimensions of image but at the same time it changes the shape of image i.e the circle in image which I also need to detect looks like oval instead of being cirle. I need your suggestions to resolve this problem. I am really grateful to you people.
Resizing images is done by either subsampling (to get smaller images) or some kind of interpolation (to get larger images)
Input is either a factor or a final dimension for width and height.
The only way to fit a rectangle into a square by simply resizing it is to use different scales for width and height. Which of course will yield in a distorted image.
To achieve what you want you can either crop a 700x700 region from your image or resize image using the same factor for with and height. Then you can fit the larger dimension into 700 and fill the rest around the other dimension with black or whatever you prefer.

How to auto-crop a barrel-distorted image using ImageMagick?

Using ImageMagick's convert to barrel-distort a photo to correct a strongly visible pincushion distortion, I provide positive a, b or c values (from a database for my lens + focal length). This results in an image that is corrected, has the original width and height, but includes a non-rectangular, bent/distorted border, as the image is corrected towards its center. Simplified example:
convert rose: -virtual-pixel black -distort Barrel '+0.0 +0.1 +0.0' out.png
How can I automatically crop the black, bent border to the largest possible rectangle in the original aspect ratio within the rose?
The ImageMagick website says, that a parameter "d" is automatically calculated, that could do this (resulting in linear distortion effectively zooming into the image and pushing the bent border right outside the image bounds), but the imagemagick-calculated value seems to aim for something different (v6.6.9 on ubuntu 12.04). If I guess and manually specify a "d", I can get the intended result:
convert rose: -virtual-pixel black -distort Barrel '+0.0 +0.1 +0.0 +0.6' out.png
The given formular a+b+c+d=1 does not seem to be a proper d for my cropping case. Also, d seems to depend on the aspect ratio of the image and not only on a/b/c. How do I make ImageMagick crop the image, or, how to I calculate a proper d?
Update
I found Fred's ImageMagick script innercrop (http://www.fmwconcepts.com/imagemagick/innercrop/index.php) that does a bit what I need, but has drawbacks and is no solution for me. It asumes arbitrary outer areas, so it takes long to find the cropping rectangle. It does not work within Unix pipes, and it does not keep the original aspect ratio.
Update 2
Contemplating on the problem makes me think that calculating a "d" is not the solution, as changing d introduces more or less bending and seems to do more than just zoom. The d=1-(a+b+c) that is calculated by imagemagick results in the bent image touching the upper/lower bounds (for landscape images) or the left/right bounds (for portrait images). So I think the proper solution would be to calculate where one of the new 4 corners will be given a/b/c/d, and then crop to those new corners.
The way I understand the docs, you do not use commas to separate the parameters for the barrel-distort operator.
Here is an example image, alongside the output of the two commands you gave:
convert o.png -virtual-pixel black -distort Barrel '+0.0 +0.1 +0.0' out0.png
convert o.png -virtual-pixel black -distort Barrel '+0.0 +0.1 +0.0 +0.6' out1.png
I created the example image in order to better visualize what you possibly want to achieve.
However, I do not see the point you stated about the automatically calculated parameter 'd', and I do not see the effect you stated about using 'd=+0.6'...
I'm not sure I understand your wanted result correctly, so I'm assuming you want the area marked by the yellow rectangle cropped.
The image on the left is out0.png as created by the first command above.
In order to guess the required coordinates, we have to determine the image dimensions first:
identify out0.png
out0.png PNG 700x700 700x700+0+0 8-bit sRGB 36KB 0.000u 0:00.000
The image in the center is marked up with the white rectangle. The rectangle is there so you can look at it and tell me if that is the region you want cropped. The image on the right is the cropped image (without scaling it back to the original size).
Is this what you want? If yes, I can possibly update the answer in order to automatically determine the required coordinates of the cropping. (For now I've done it based on guessing.)
Update
I think you may have mis-understood the purpose of the barrel-distortion operation. It is meant for correcting a barrel (slight) distortion, as is produced by camera lenses. The 3 parameters a, b and c to be used for any specific combination of camera, lens and current zoom could possibly be stated in your photo's EXIF data. The formula were a+b+c+d = 1 is meant to be used when the new, distortion-corrected image should have the same dimensions as the original (distorted) image.
So to imitate the barrel-correction, we should probably use the second image from the last row above as our input:
convert out3.png -virtual-pixel gray -distort barrel '0 -0.2 0' corrected.png
Result:

Android custom input component with graphical representation?

I am looking all over the net to find out a code to make a custom input component that I need but didn't stumble upon anything similar. Here's how I'd like it to work:
the purpose is to input the quantity (a number)
the quantity is to be changed with two buttons (+ & -)
there should be a button to accept the input
Here's the tricky part - the graphical representation of the input:
I'd like to have two pictures representing the currently selected quantity in the following way:
q = 0:
Both pictures are dimmed
q = 1:
The upper-left quarter of the first picture is bright (normal) and the rest is dimmed
q = 2:
The upper half of the first picture is bright (normal) and the rest is dimmed
q = 3:
The upper half + lower-left quarter of the first picture is bright (normal) and the rest is dimmed
q = 4:
The first picture is bright and the second one is dimmed
q = 5:
The first picture is bright and the upper-left quarter of the second picture is bright
.
.
.
q = 8:
Both pictures are bright.
I hope I've explained that in an understandable way.
The question is:
Do I have to make 5 instances of each picture (dimmed, bright upper-left quarter, bright upper half, bright upper half + lower-left quarter, bright) or is it possible to have only one instance of each picture (bright) and to dim the portions (as necessary) with the code?
Of course, I'd appreciate a link to anything that would be of any help or chunk of the code.
I think you should be able to handle all of your conditions with just 2 images. But use a combination linearlayout,framelayout and imageviews. Some thing like this to represent one image.
FrameLayout
Imageview
LinearLayout (Divided to 4 cells using the weight property)
You can change the alpha value of the bg color of the linear layouts to get the dimmed effect.
This can also be done using different slices of the images and changing the alpha value of the imageview. You will need to find what suits you more. It wont be easy to find any code samples as this is not a common UI found in apps.